mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-07 17:27:36 +00:00
62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace Magento\Webapi\Test\Unit\Controller\Rest;
|
|
|
|
use Magento\Authorization\Model\UserContextInterface;
|
|
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
|
use Magento\Webapi\Controller\Rest\ParamOverriderCustomerId;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ParamOverriderCustomerIdTest extends TestCase
|
|
{
|
|
/**
|
|
* @var ParamOverriderCustomerId
|
|
*/
|
|
private $model;
|
|
|
|
/**
|
|
* @var UserContextInterface
|
|
*/
|
|
private $userContext;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->userContext = $this->getMockBuilder(UserContextInterface::class)
|
|
->getMockForAbstractClass();
|
|
$this->model = (new ObjectManager($this))->getObject(
|
|
ParamOverriderCustomerId::class,
|
|
[
|
|
'userContext' => $this->userContext
|
|
]
|
|
);
|
|
}
|
|
|
|
public function testGetOverriddenValueIsCustomer()
|
|
{
|
|
$retValue = 'retValue';
|
|
|
|
$this->userContext->expects($this->once())
|
|
->method('getUserType')
|
|
->willReturn(UserContextInterface::USER_TYPE_CUSTOMER);
|
|
$this->userContext->expects($this->once())
|
|
->method('getUserId')
|
|
->willReturn($retValue);
|
|
|
|
$this->assertSame($retValue, $this->model->getOverriddenValue());
|
|
}
|
|
|
|
public function testGetOverriddenValueIsNotCustomer()
|
|
{
|
|
$this->userContext->expects($this->once())
|
|
->method('getUserType')
|
|
->willReturn(UserContextInterface::USER_TYPE_ADMIN);
|
|
|
|
$this->assertNull($this->model->getOverriddenValue());
|
|
}
|
|
}
|