159 lines
4.5 KiB
PHP
159 lines
4.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*
|
|
* https://www.d3data.de
|
|
*
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
* @link https://www.oxidmodule.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace D3\Usermanager\tests\unit\Application\Controller\Admin;
|
|
|
|
use D3\Usermanager\Application\Controller\Admin\d3_cfg_usermanageritem_main;
|
|
use D3\Usermanager\Application\Model\d3usermanager;
|
|
use D3\Usermanager\tests\unit\d3UsermanagerUnitTestCase;
|
|
use Exception;
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
use ReflectionException;
|
|
|
|
/**
|
|
* @covers \D3\Usermanager\Application\Controller\Admin\d3_cfg_usermanageritem_main
|
|
*/
|
|
class d3_cfg_usermanageritem_mainTest extends d3UsermanagerUnitTestCase
|
|
{
|
|
/** @var d3_cfg_usermanageritem_main */
|
|
protected $_oController;
|
|
|
|
/**
|
|
* setup basic requirements
|
|
* @throws DatabaseConnectionException
|
|
* @throws DatabaseErrorException
|
|
* @throws Exception
|
|
*/
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->_oController = d3GetOxidDIC()->get(d3_cfg_usermanageritem_main::class);
|
|
}
|
|
|
|
public function tearDown(): void
|
|
{
|
|
parent::tearDown();
|
|
|
|
unset($this->_oController);
|
|
}
|
|
|
|
/**
|
|
* @covers \D3\Usermanager\Application\Controller\Admin\d3_cfg_usermanageritem_main::render
|
|
* @test
|
|
* @throws ReflectionException
|
|
*/
|
|
public function renderPass()
|
|
{
|
|
$this->assertSame(
|
|
'@d3usermanager/admin/d3_cfg_usermanageritem_main',
|
|
$this->callMethod($this->_oController, 'render')
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @covers \D3\Usermanager\Application\Controller\Admin\d3_cfg_usermanageritem_main::addDefaultValues
|
|
* @test
|
|
* @throws ReflectionException
|
|
*/
|
|
public function changeDefaultValuesPostPass()
|
|
{
|
|
$_POST = [
|
|
'editval' => ['d3modprofile__d3_cronjobid' => 'foo'],
|
|
];
|
|
|
|
/** @var d3_cfg_usermanageritem_main|MockObject $oControllerMock */
|
|
$oControllerMock = $this->getMockBuilder(d3_cfg_usermanageritem_main::class)
|
|
->onlyMethods(['fixCronjobId'])
|
|
->getMock();
|
|
$oControllerMock->method('fixCronjobId')->willReturn('newCjId');
|
|
|
|
$this->_oController = $oControllerMock;
|
|
|
|
$this->assertSame(
|
|
['foo' => 'bar'],
|
|
$this->callMethod($this->_oController, 'addDefaultValues', [['foo' => 'bar']])
|
|
);
|
|
|
|
$this->assertEquals('newCjId', $_POST['editval']['d3modprofile__d3_cronjobid']);
|
|
}
|
|
|
|
/**
|
|
* @covers \D3\Usermanager\Application\Controller\Admin\d3_cfg_usermanageritem_main::addDefaultValues
|
|
* @test
|
|
* @throws ReflectionException
|
|
*/
|
|
public function changeDefaultValuesGetPass()
|
|
{
|
|
$_GET = [
|
|
'editval' => ['d3modprofile__d3_cronjobid' => 'foo'],
|
|
];
|
|
|
|
/** @var d3_cfg_usermanageritem_main|MockObject $oControllerMock */
|
|
$oControllerMock = $this->getMockBuilder(d3_cfg_usermanageritem_main::class)
|
|
->onlyMethods(['fixCronjobId'])
|
|
->getMock();
|
|
$oControllerMock->method('fixCronjobId')->willReturn('newCjId');
|
|
|
|
$this->_oController = $oControllerMock;
|
|
|
|
$this->assertSame(
|
|
['foo' => 'bar'],
|
|
$this->callMethod($this->_oController, 'addDefaultValues', [['foo' => 'bar']])
|
|
);
|
|
|
|
$this->assertEquals('newCjId', $_GET['editval']['d3modprofile__d3_cronjobid']);
|
|
}
|
|
|
|
/**
|
|
* @covers \D3\Usermanager\Application\Controller\Admin\d3_cfg_usermanageritem_main::fixCronjobId
|
|
* @test
|
|
* @throws ReflectionException
|
|
*/
|
|
public function fixCronJobIdPass()
|
|
{
|
|
$this->assertEquals(
|
|
'test_Id',
|
|
$this->callMethod(
|
|
$this->_oController,
|
|
'fixCronjobId',
|
|
['test Id']
|
|
)
|
|
);
|
|
$this->assertEquals(
|
|
'test-Id',
|
|
$this->callMethod(
|
|
$this->_oController,
|
|
'fixCronjobId',
|
|
['test-Id']
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param $sLicenseKey
|
|
* @param d3usermanager $oManager
|
|
* @return null
|
|
*/
|
|
protected function _setModuleLicenseKey($sLicenseKey, $oManager = null)
|
|
{
|
|
return null;
|
|
}
|
|
}
|