Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ElGigi committed Jul 7, 2021
1 parent 9a0eba1 commit 1e38ecc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/App/CliApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
namespace Berlioz\Cli\Core\App;

use Berlioz\Cli\Core\Command\CommandHandler;
use Berlioz\Cli\Core\Container\ServiceProvider;
use Berlioz\Cli\Core\Exception\CliException;
use Berlioz\Config\Adapter\JsonAdapter;
use Berlioz\Config\Config;
use Berlioz\Config\Exception\ConfigException;
use Berlioz\Core\App\AbstractApp;
use Berlioz\Core\Core;
use Berlioz\ServiceContainer\Inflector\Inflector;

/**
Expand Down
6 changes: 4 additions & 2 deletions tests/Command/AbstractCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ public function testGetHelp()
public function testRun()
{
$declaration = new CommandDeclaration('foo', FakeCommand::class, []);
$command = new FakeCommand(new CliApp(new Core(new FakeDefaultDirectories(), cache: false)));
$command = new FakeCommand();
$command->setApp(new CliApp(new Core(new FakeDefaultDirectories(), cache: false)));

$this->assertSame(0, $command->run(new Environment(new Console(), $declaration)));
}

public function testGet()
{
$command = new FakeCommand($app = new CliApp(new Core(new FakeDefaultDirectories(), cache: false)));
$command = new FakeCommand();
$command->setApp($app = new CliApp(new Core(new FakeDefaultDirectories(), cache: false)));
$reflectionClass = new ReflectionClass(AbstractCommand::class);
$reflectionMethod = $reflectionClass->getMethod('get');
$reflectionMethod->setAccessible(true);
Expand Down
6 changes: 4 additions & 2 deletions tests/Command/Berlioz/CacheClearCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function testClearCache()
{
$app = new CliApp(new Core(new FakeDefaultDirectories(), cache: false));
$app->getCore()->getCache()->set('foo', 'bar');
$command = new CacheClearCommand($app);
$command = new CacheClearCommand();
$command->setApp($app);

$this->assertEquals('bar', $app->getCore()->getCache()->get('foo'));
$this->assertTrue($command->clearCache());
Expand All @@ -48,7 +49,8 @@ public function testRun()
{
$app = new CliApp(new Core(new FakeDefaultDirectories(), cache: false));
$app->getCore()->getCache()->set('foo', 'bar');
$command = new CacheClearCommand($app);
$command = new CacheClearCommand();
$command->setApp($app);
$console = new Console();
$console->output->defaultTo('buffer');

Expand Down
6 changes: 3 additions & 3 deletions tests/Command/Berlioz/ConfigCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Berlioz\Cli\Core\Console\Environment;
use Berlioz\Cli\Core\Tests\FakeDefaultDirectories;
use Berlioz\Core\Core;
use GetOpt\GetOpt;
use PHPUnit\Framework\TestCase;

class ConfigCommandTest extends TestCase
Expand All @@ -38,12 +37,13 @@ public function testGetHelp()
public function testRun()
{
$app = new CliApp(new Core(new FakeDefaultDirectories(), cache: false));
$command = new ConfigCommand($app);
$command = new ConfigCommand();
$command->setApp($app);
$console = new Console();
$console->output->defaultTo('buffer');
$console->getArgumentsManager()->add('filter', []);

$result =$command->run(
$result = $command->run(
new Environment(
$console,
new CommandDeclaration('berlioz:config', ConfigCommand::class, [new Argument('filter')])
Expand Down

0 comments on commit 1e38ecc

Please sign in to comment.