2019-08-08 23:50:09 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2022-09-26 15:22:26 +02:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2019-08-08 23:50:09 +02:00
|
|
|
*
|
2022-09-26 15:22:26 +02:00
|
|
|
* https://www.d3data.de
|
2019-08-08 23:50:09 +02:00
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
2022-09-26 15:22:26 +02:00
|
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
2019-08-08 23:50:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace D3\Totp\tests\unit\Modules\Application\Model;
|
|
|
|
|
|
|
|
use D3\Totp\Application\Model\d3totp;
|
|
|
|
use D3\Totp\Modules\Application\Model\d3_totp_user;
|
|
|
|
use D3\Totp\tests\unit\d3TotpUnitTestCase;
|
|
|
|
use OxidEsales\Eshop\Application\Model\User;
|
|
|
|
use OxidEsales\Eshop\Core\Session;
|
2022-09-28 00:08:36 +02:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2019-08-08 23:50:09 +02:00
|
|
|
use ReflectionException;
|
|
|
|
|
|
|
|
class d3_totp_userTest extends d3TotpUnitTestCase
|
|
|
|
{
|
|
|
|
/** @var d3_totp_user */
|
|
|
|
protected $_oModel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setup basic requirements
|
|
|
|
*/
|
2022-09-28 00:08:36 +02:00
|
|
|
public function setUp(): void
|
2019-08-08 23:50:09 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->_oModel = oxNew(User::class);
|
|
|
|
}
|
|
|
|
|
2022-09-28 00:08:36 +02:00
|
|
|
public function tearDown(): void
|
2019-08-08 23:50:09 +02:00
|
|
|
{
|
|
|
|
parent::tearDown();
|
|
|
|
|
|
|
|
unset($this->_oModel);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws ReflectionException
|
2022-09-28 22:25:51 +02:00
|
|
|
* @covers \D3\Totp\Modules\Application\Model\d3_totp_user::logout
|
2019-08-08 23:50:09 +02:00
|
|
|
*/
|
|
|
|
public function logout()
|
|
|
|
{
|
2022-09-28 00:08:36 +02:00
|
|
|
/** @var Session|MockObject $oSessionMock */
|
|
|
|
$oSessionMock = $this->getMockBuilder(Session::class)
|
|
|
|
->onlyMethods(['deleteVariable'])
|
|
|
|
->getMock();
|
2019-08-08 23:50:09 +02:00
|
|
|
$oSessionMock->expects($this->once())->method('deleteVariable')->willReturn(true);
|
|
|
|
|
2022-09-28 00:08:36 +02:00
|
|
|
/** @var d3_totp_user|MockObject $oModelMock */
|
|
|
|
$oModelMock = $this->getMockBuilder(User::class)
|
|
|
|
->onlyMethods(['d3GetSession'])
|
|
|
|
->getMock();
|
2019-08-08 23:50:09 +02:00
|
|
|
$oModelMock->method('d3GetSession')->willReturn($oSessionMock);
|
|
|
|
|
|
|
|
$this->_oModel = $oModelMock;
|
|
|
|
|
|
|
|
$this->assertTrue(
|
|
|
|
$this->callMethod(
|
|
|
|
$this->_oModel,
|
|
|
|
'logout'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws ReflectionException
|
2022-09-28 22:25:51 +02:00
|
|
|
* @covers \D3\Totp\Modules\Application\Model\d3_totp_user::d3getTotp
|
2019-08-08 23:50:09 +02:00
|
|
|
*/
|
|
|
|
public function d3getTotpReturnsRightInstance()
|
|
|
|
{
|
|
|
|
$this->assertInstanceOf(
|
|
|
|
d3totp::class,
|
|
|
|
$this->callMethod($this->_oModel, 'd3getTotp')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws ReflectionException
|
2022-09-28 22:25:51 +02:00
|
|
|
* @covers \D3\Totp\Modules\Application\Model\d3_totp_user::d3GetSession
|
2019-08-08 23:50:09 +02:00
|
|
|
*/
|
|
|
|
public function d3GetSessionReturnsRightInstance()
|
|
|
|
{
|
|
|
|
$this->assertInstanceOf(
|
|
|
|
Session::class,
|
|
|
|
$this->callMethod($this->_oModel, 'd3GetSession')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|