Skip to content

Commit 48552a5

Browse files
author
okarpenko
committed
MAGETWO-38155: Create block for order level
1 parent c332434 commit 48552a5

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\TestFramework\TestCase\WebapiAbstract;
1414
use Magento\User\Model\User as UserModel;
1515
use Magento\Framework\Webapi\Exception as HTTPExceptionCodes;
16+
use Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory;
1617

1718
/**
1819
* api-functional test for \Magento\Integration\Model\CustomerTokenService.
@@ -35,9 +36,9 @@ class CustomerTokenServiceTest extends WebapiAbstract
3536
private $customerAccountManagement;
3637

3738
/**
38-
* @var TokenModel
39+
* @var CollectionFactory
3940
*/
40-
private $tokenModel;
41+
private $tokenCollection;
4142

4243
/**
4344
* @var UserModel
@@ -54,19 +55,21 @@ public function setUp()
5455
$this->customerAccountManagement = Bootstrap::getObjectManager()->get(
5556
'Magento\Customer\Api\AccountManagementInterface'
5657
);
57-
$this->tokenModel = Bootstrap::getObjectManager()->get('Magento\Integration\Model\Oauth\Token');
58+
$tokenCollectionFactory = Bootstrap::getObjectManager()->get(
59+
'Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory'
60+
);
61+
$this->tokenCollection = $tokenCollectionFactory->create();
5862
$this->userModel = Bootstrap::getObjectManager()->get('Magento\User\Model\User');
5963
}
6064

6165
/**
6266
* @magentoApiDataFixture Magento/Customer/_files/customer.php
63-
* @magentoAppIsolation enabled
64-
* @magentoDbIsolation enabled
6567
*/
6668
public function testCreateCustomerAccessToken()
6769
{
6870
$customerUserName = 'customer@example.com';
6971
$password = 'password';
72+
$isTokenCorrect = false;
7073

7174
$serviceInfo = [
7275
'rest' => [
@@ -78,9 +81,17 @@ public function testCreateCustomerAccessToken()
7881
$accessToken = $this->_webApiCall($serviceInfo, $requestData);
7982

8083
$customerData = $this->customerAccountManagement->authenticate($customerUserName, $password);
81-
/** @var $token TokenModel */
82-
$token = $this->tokenModel->loadByCustomerId($customerData->getId())->getToken();
83-
$this->assertEquals($accessToken, $token);
84+
85+
/** @var $this->tokenCollection \Magento\Integration\Model\Resource\Oauth\Token\Collection */
86+
$this->tokenCollection->addFilterByCustomerId($customerData->getId());
87+
88+
foreach ($this->tokenCollection->getItems() as $item) {
89+
/** @var $item TokenModel */
90+
if ($item->getToken() == $accessToken) {
91+
$isTokenCorrect = true;
92+
}
93+
}
94+
$this->assertTrue($isTokenCorrect);
8495
}
8596

8697
/**

0 commit comments

Comments
 (0)