Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ParamOverriderCustomerIdTest.php
Go to the documentation of this file.
1 <?php
8 
12 
13 class ParamOverriderCustomerIdTest extends \PHPUnit\Framework\TestCase
14 {
18  private $model;
19 
23  private $userContext;
24 
25  protected function setUp()
26  {
27  $this->userContext = $this->getMockBuilder(\Magento\Authorization\Model\UserContextInterface::class)
28  ->getMockForAbstractClass();
29  $this->model = (new ObjectManager($this))->getObject(
30  \Magento\Webapi\Controller\Rest\ParamOverriderCustomerId::class,
31  [
32  'userContext' => $this->userContext
33  ]
34  );
35  }
36 
38  {
39  $retValue = 'retValue';
40 
41  $this->userContext->expects($this->once())
42  ->method('getUserType')
43  ->will($this->returnValue(UserContextInterface::USER_TYPE_CUSTOMER));
44  $this->userContext->expects($this->once())
45  ->method('getUserId')
46  ->will($this->returnValue($retValue));
47 
48  $this->assertSame($retValue, $this->model->getOverriddenValue());
49  }
50 
52  {
53  $this->userContext->expects($this->once())
54  ->method('getUserType')
55  ->will($this->returnValue(UserContextInterface::USER_TYPE_ADMIN));
56 
57  $this->assertNull($this->model->getOverriddenValue());
58  }
59 }