userContext = $this->getMockBuilder(\Magento\Authorization\Model\UserContextInterface::class) ->getMockForAbstractClass(); $this->model = (new ObjectManager($this))->getObject( \Magento\Webapi\Controller\Rest\ParamOverriderCustomerId::class, [ 'userContext' => $this->userContext ] ); } public function testGetOverriddenValueIsCustomer() { $retValue = 'retValue'; $this->userContext->expects($this->once()) ->method('getUserType') ->will($this->returnValue(UserContextInterface::USER_TYPE_CUSTOMER)); $this->userContext->expects($this->once()) ->method('getUserId') ->will($this->returnValue($retValue)); $this->assertSame($retValue, $this->model->getOverriddenValue()); } public function testGetOverriddenValueIsNotCustomer() { $this->userContext->expects($this->once()) ->method('getUserType') ->will($this->returnValue(UserContextInterface::USER_TYPE_ADMIN)); $this->assertNull($this->model->getOverriddenValue()); } }