-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
also thrown an exception when provided store is not enabled
Closes #871
- Loading branch information
Showing
2 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/code/Magento/StoreGraphQl/Test/Integration/StoreValidatorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\StoreGraphQl\Test\Integration; | ||
|
||
use Magento\Framework\App\Request\Http; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\Registry; | ||
use Magento\Store\Model\Store; | ||
use Magento\StoreGraphQl\Controller\HttpRequestValidator\StoreValidator; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use PHPUnit\Framework\TestCase; | ||
use Zend\Http\Headers; | ||
|
||
class StoreValidatorTest extends TestCase | ||
{ | ||
/** | ||
* @var Store | ||
*/ | ||
private $disabledStore; | ||
|
||
/** | ||
* @var StoreValidator | ||
*/ | ||
private $storeValidator; | ||
|
||
/** | ||
* @var Http | ||
*/ | ||
private $httpRequest; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->storeValidator = Bootstrap::getObjectManager()->create(StoreValidator::class); | ||
$this->httpRequest = Bootstrap::getObjectManager()->create(Http::class); | ||
} | ||
|
||
protected function setUp() | ||
{ | ||
Bootstrap::getObjectManager()->get(Registry::class)->register('isSecureArea', true); | ||
|
||
$this->disabledStore = Bootstrap::getObjectManager()->create(Store::class) | ||
->setCode('inactive_store') | ||
->setWebsiteId(1) | ||
->setGroupId(1) | ||
->setName('Inactive Store') | ||
->setIsActive(false) | ||
->save(); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
$this->disabledStore->delete(); | ||
Bootstrap::getObjectManager()->get(Registry::class)->unregister('isSecureArea'); | ||
} | ||
|
||
public function testExceptionIsThrownWhenStoreIsNotValid() | ||
{ | ||
$this->expectException(GraphQlInputException::class); | ||
$this->httpRequest->setHeaders(Headers::fromString('Store: inactive_store')); | ||
$this->storeValidator->validate($this->httpRequest); | ||
} | ||
|
||
public function testExceptionIsThrownWhenStoreDoesNotExist() | ||
{ | ||
$this->expectException(GraphQlInputException::class); | ||
$this->httpRequest->setHeaders(Headers::fromString('Store: nonexistent_store')); | ||
$this->storeValidator->validate($this->httpRequest); | ||
} | ||
} |