Skip to content

Commit

Permalink
PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Sep 2, 2023
1 parent 3e16249 commit 52af249
Showing 1 changed file with 22 additions and 112 deletions.
134 changes: 22 additions & 112 deletions tests/Unit/Libraries/Cms/MVC/Controller/BaseControllerTest.php
Expand Up @@ -81,11 +81,7 @@ public function getInput(): Input
*/
public function testGetInjectedName()
{
$controller = new class (
['name' => 'unit test', 'base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['name' => 'unit test', 'base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
};

$this->assertEquals('unit test', $controller->getName());
Expand All @@ -100,11 +96,7 @@ public function testGetInjectedName()
*/
public function testGetCompiledName()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
};

$this->assertStringContainsStringIgnoringCase('base', $controller->getName());
Expand All @@ -119,11 +111,7 @@ public function testGetCompiledName()
*/
public function testAvailableTasks()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
public function unit()
{
}
Expand All @@ -141,11 +129,7 @@ public function unit()
*/
public function testUnregisterTask()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
public function list()
{
return $this->taskMap;
Expand All @@ -165,11 +149,7 @@ public function list()
*/
public function testExecuteTask()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
public function unit()
{
return 'unit test';
Expand All @@ -189,11 +169,7 @@ public function unit()
*/
public function testExecuteInjectedDefaultTask()
{
$controller = new class (
['default_task' => 'unit', 'base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['default_task' => 'unit', 'base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
public function unit()
{
return 'unit test';
Expand All @@ -213,11 +189,7 @@ public function unit()
*/
public function testExecuteDisplayDefaultTask()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
public function display($cachable = false, $urlparams = [])
{
return 'unit test';
Expand All @@ -237,11 +209,7 @@ public function display($cachable = false, $urlparams = [])
*/
public function testExecuteTaskWhichDoesntExist()
{
$controller = new class (
['default_task' => 'invalid', 'base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['default_task' => 'invalid', 'base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
};

$this->expectException(\Exception::class);
Expand All @@ -263,12 +231,7 @@ public function testGetModel()
};
$mvcFactory->method('createModel')->willReturn($model);

$controller = new class (
['base_path' => __DIR__],
$mvcFactory,
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $mvcFactory, $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
};

$this->assertEquals($model, $controller->getModel());
Expand All @@ -286,12 +249,7 @@ public function testGetModelWithInjectedPrefix()
$mvcFactory = $this->createMock(LegacyFactory::class);
$mvcFactory->expects($this->once())->method('createModel')->with($this->equalTo('Unit'), $this->equalTo('Test'));

$controller = new class (
['model_prefix' => 'Test', 'base_path' => __DIR__],
$mvcFactory,
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['model_prefix' => 'Test', 'base_path' => __DIR__], $mvcFactory, $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
};
$controller->getModel('Unit');
}
Expand Down Expand Up @@ -327,12 +285,7 @@ public function testGetNullModel()
{
$mvcFactory = $this->createStub(MVCFactoryInterface::class);

$controller = new class (
['base_path' => __DIR__],
$mvcFactory,
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $mvcFactory, $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
};

$this->assertFalse($controller->getModel());
Expand All @@ -359,7 +312,7 @@ public function getUser(): User
$mvcFactory->method('createModel')->willReturn($model);

$user = new User();
$app = $this->createStub(CMSApplicationInterface::class);
$app = $this->createStub(CMSApplicationInterface::class);
$app->method('getIdentity')->willReturn($user);

$controller = new class (['base_path' => __DIR__], $mvcFactory, $app, new Input()) extends BaseController {
Expand All @@ -385,12 +338,7 @@ public function display($tpl = null)
$mvcFactory = $this->createStub(MVCFactoryInterface::class);
$mvcFactory->method('createView')->willReturn($view);

$controller = new class (
['base_path' => __DIR__],
$mvcFactory,
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $mvcFactory, $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
};

$this->assertEquals($view, $controller->getView('testGetView'));
Expand All @@ -409,12 +357,7 @@ public function testGetViewWithInjectedPrefix()
$mvcFactory->expects($this->once())->method('createView')->with($this->equalTo('Unit'), $this->equalTo('TestView'))
->willReturn($this->createStub(AbstractView::class));

$controller = new class (
['name' => 'Test', 'base_path' => __DIR__],
$mvcFactory,
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['name' => 'Test', 'base_path' => __DIR__], $mvcFactory, $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
};
$controller->getView('Unit');
}
Expand All @@ -430,12 +373,7 @@ public function testGetNullView()
{
$mvcFactory = $this->createStub(MVCFactoryInterface::class);

$controller = new class (
['base_path' => __DIR__],
$mvcFactory,
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $mvcFactory, $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
};

$this->expectException(\Exception::class);
Expand Down Expand Up @@ -468,7 +406,7 @@ public function getUser(): User
$mvcFactory->method('createView')->willReturn($view);

$user = new User();
$app = $this->createStub(CMSApplicationInterface::class);
$app = $this->createStub(CMSApplicationInterface::class);
$app->method('getIdentity')->willReturn($user);

$controller = new class (['base_path' => __DIR__], $mvcFactory, $app, new Input()) extends BaseController {
Expand All @@ -487,11 +425,7 @@ public function getUser(): User
public function testInjectViewPath()
{
$path = dirname(__DIR__);
$controller = new class (
['view_path' => $path, 'base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['view_path' => $path, 'base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
public function getPaths()
{
return $this->paths;
Expand All @@ -511,11 +445,7 @@ public function getPaths()
*/
public function testAddViewPath()
{
$controller = new class (
['name' => 'unit test', 'base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class)
) extends BaseController {
$controller = new class (['name' => 'unit test', 'base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class)) extends BaseController {
public function getPaths()
{
return $this->paths;
Expand Down Expand Up @@ -752,12 +682,7 @@ public function releaseEditId($context, $id)
*/
public function testSetRedirect()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
public function getRedirect()
{
return $this->redirect;
Expand Down Expand Up @@ -789,12 +714,7 @@ public function getMessageType()
*/
public function testSetRedirectWithEmptyType()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
public function getMessageType()
{
return $this->messageType;
Expand Down Expand Up @@ -840,12 +760,7 @@ public function redirect()
*/
public function testSetMessage()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
public function getMessage()
{
return $this->message;
Expand All @@ -871,12 +786,7 @@ public function getMessageType()
*/
public function testSetMessageTwice()
{
$controller = new class (
['base_path' => __DIR__],
$this->createStub(MVCFactoryInterface::class),
$this->createStub(CMSApplicationInterface::class),
new Input()
) extends BaseController {
$controller = new class (['base_path' => __DIR__], $this->createStub(MVCFactoryInterface::class), $this->createStub(CMSApplicationInterface::class), new Input()) extends BaseController {
public function getMessage()
{
return $this->message;
Expand Down

0 comments on commit 52af249

Please sign in to comment.