Skip to content

Commit

Permalink
[#13648] - Reformatting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niden committed May 15, 2019
1 parent c5ca361 commit 6133522
Show file tree
Hide file tree
Showing 28 changed files with 351 additions and 382 deletions.
10 changes: 8 additions & 2 deletions phalcon/Cli/Console.zep
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,23 @@ use Phalcon\Events\ManagerInterface;
*/
class Console extends BaseApplication
{
/**
* @var array
*/
protected arguments = [];

/**
* @var array
*/
protected options = [];

/**
* Handle the whole command-line tasks
*/
public function handle(array arguments = null)
{
var container, router, eventsManager, moduleName, modules, module, path,
className, moduleObject, dispatcher, task;
var className, container, dispatcher, eventsManager, module, moduleName,
moduleObject, modules, path, router, task;

let container = this->container;

Expand Down
5 changes: 3 additions & 2 deletions tests/cli/Cli/Console/GetModuleCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use CliTester;
use Phalcon\Application\Exception;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Modules\Frontend\Module;

class GetModuleCest
{
Expand All @@ -38,7 +39,7 @@ public function cliConsoleGetModule(CliTester $I)
$console->registerModules(
[
'frontend' => [
'className' => \Phalcon\Test\Modules\Frontend\Module::class,
'className' => Module::class,
'path' => dataDir('fixtures/modules/frontend/Module.php'),
],
'backend' => [
Expand All @@ -49,7 +50,7 @@ public function cliConsoleGetModule(CliTester $I)
);

$expected = [
'className' => \Phalcon\Test\Modules\Frontend\Module::class,
'className' => Module::class,
'path' => dataDir('fixtures/modules/frontend/Module.php'),
];

Expand Down
15 changes: 7 additions & 8 deletions tests/cli/Cli/Console/HandleCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
namespace Phalcon\Test\Cli\Cli\Console;

use CliTester;
use function dataDir;
use Exception;
use Phalcon\Events\Event;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use function dataDir;
use Phalcon\Test\Modules\Backend\Module;

class HandleCest
{
Expand Down Expand Up @@ -226,7 +227,7 @@ function (Event $event, $console, $moduleName) {
'path' => dataDir('fixtures/modules/frontend/Module.php'),
],
'backend' => [
'className' => \Phalcon\Test\Modules\Backend\Module::class,
'className' => Module::class,
],
]
);
Expand Down Expand Up @@ -278,7 +279,7 @@ public function cliConsoleHandleEventAfterStartModule(CliTester $I)
'path' => dataDir('fixtures/modules/frontend/Module.php'),
],
'backend' => [
'className' => \Phalcon\Test\Modules\Backend\Module::class,
'className' => Module::class,
],
]
);
Expand Down Expand Up @@ -377,7 +378,7 @@ function (Event $event, $console, $moduleObject) {
'path' => dataDir('fixtures/modules/frontend/Module.php'),
],
'backend' => [
'className' => \Phalcon\Test\Modules\Backend\Module::class,
'className' => Module::class,
],
]
);
Expand Down Expand Up @@ -412,7 +413,6 @@ public function cliConsoleHandle13724(CliTester $I)
$I->wantToTest("Cli\Console - handle() - Issue #13724");



$console = $this->newCliConsole();

$this->setNewCliFactoryDefault();
Expand All @@ -422,7 +422,7 @@ public function cliConsoleHandle13724(CliTester $I)
$console->registerModules(
[
'backend' => [
'className' => \Phalcon\Test\Modules\Backend\Module::class,
'className' => Module::class,
'path' => dataDir('fixtures/modules/backend/Module.php'),
],
]
Expand All @@ -436,7 +436,6 @@ public function cliConsoleHandle13724(CliTester $I)
);



$console = $this->newCliConsole();

$this->setNewCliFactoryDefault();
Expand All @@ -446,7 +445,7 @@ public function cliConsoleHandle13724(CliTester $I)
$console->registerModules(
[
'backend' => [
'className' => \Phalcon\Test\Modules\Backend\Module::class,
'className' => Module::class,
'path' => dataDir('fixtures/modules/backend/Module.php'),
],
]
Expand Down
22 changes: 18 additions & 4 deletions tests/cli/Cli/Console/RegisterModulesCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
namespace Phalcon\Test\Cli\Cli\Console;

use CliTester;
use Phalcon\Cli\Console;
use Phalcon\Cli\Console\Exception;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use Phalcon\Test\Modules\Frontend\Module;

Expand Down Expand Up @@ -99,21 +101,33 @@ public function cliConsoleRegisterModules(CliTester $I)
);
}

public function badPathThrowsAnException(CliTester $I)
/**
* Tests Phalcon\Cli\Console :: registerModules() - bad path throws exception
*
* @author Phalcon Team <team@phalconphp.com>
* @since 2018-11-13
*
* @author Nathan Edwards <https://github.com/npfedwards>
* @since 2018-26-12
*/
public function cliConsoleRegisterModulesBadPathThrowsAnException(CliTester $I)
{
$I->wantToTest("Cli\Console - registerModules() - bad path throws exception");
$I->skipTest('This needs to be checked');

$console = $this->newCliConsole();

$console->registerModules(
[
'frontend' => [
'path' => dataDir('not-a-real-file.php'),
'className' => \Phalcon\Test\Modules\Frontend\Module::class,
'className' => Module::class,
],
]
);

$I->expectException(
new \Phalcon\Cli\Console\Exception(
$I->expectThrowable(
new Exception(
"Module definition path 'not-a-real-file.php' doesn't exist"
),
function () use ($console) {
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/Cli/ConsoleCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
namespace Phalcon\Test\Cli\Cli;

use CliTester;
use function dataDir;
use Issue787Task;
use Phalcon\Cli\Console;
use Phalcon\Cli\Console\Exception as ConsoleException;
use Phalcon\Cli\Dispatcher;
use Phalcon\Cli\Dispatcher\Exception as DispatcherException;
use Phalcon\Cli\Router;
use Phalcon\Test\Fixtures\Traits\DiTrait;
use function dataDir;

class ConsoleCest
{
Expand Down
33 changes: 0 additions & 33 deletions tests/cli/Cli/Dispatcher/GetDICest.php

This file was deleted.

30 changes: 0 additions & 30 deletions tests/cli/Cli/Dispatcher/GetEventsManagerCest.php

This file was deleted.

41 changes: 41 additions & 0 deletions tests/cli/Cli/Dispatcher/GetSetDICest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalconphp.com>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

namespace Phalcon\Test\Cli\Cli\Dispatcher;

use CliTester;
use Phalcon\Cli\Console;
use Phalcon\Test\Fixtures\Traits\DiTrait;

class GetSetDICest
{
use DiTrait;

/**
* Tests Phalcon\Cli\Dispatcher :: getDI()/setDI()
*
* @author Phalcon Team <team@phalconphp.com>
* @since 2018-11-13
*/
public function cliDispatcherGetSetDI(CliTester $I)
{
$I->wantToTest('Cli\Dispatcher - getDI()/getDI()');

$container = $this->newCliFactoryDefault();
$console = new Console();

$console->setDI($container);

$actual = $console->getDI();
$I->assertEquals($container, $actual);
}
}
39 changes: 39 additions & 0 deletions tests/cli/Cli/Dispatcher/GetSetEventsManagerCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);

/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalconphp.com>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

namespace Phalcon\Test\Cli\Cli\Dispatcher;

use CliTester;
use Phalcon\Cli\Console;
use Phalcon\Events\Manager;

class GetSetEventsManagerCest
{
/**
* Tests Phalcon\Cli\Dispatcher :: getEventsManager()/setEventsManager()
*
* @author Phalcon Team <team@phalconphp.com>
* @since 2018-11-13
*/
public function cliDispatcherGetSetEventsManager(CliTester $I)
{
$I->wantToTest('Cli\Dispatcher - getEventsManager()/setEventsManager()');

$console = new Console();
$manager = new Manager();

$console->setEventsManager($manager);

$actual = $console->getEventsManager();
$I->assertEquals($manager, $actual);
}
}
33 changes: 0 additions & 33 deletions tests/cli/Cli/Dispatcher/SetDICest.php

This file was deleted.

Loading

0 comments on commit 6133522

Please sign in to comment.