Skip to content

Commit

Permalink
Merge 3d69c4a into 6b0a6bd
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Oct 29, 2020
2 parents 6b0a6bd + 3d69c4a commit bf6cc51
Show file tree
Hide file tree
Showing 68 changed files with 978 additions and 510 deletions.
21 changes: 14 additions & 7 deletions tests/Unit/Application/BaseApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public function addDirectories(): void
{
$directories = ['dir1', 'dir2'];
$this->subject->addDirectories($directories);
$this->assertContains('dir1', $this->subject->getDirectories());
$this->assertContains('dir2', $this->subject->getDirectories());

self::assertContains('dir1', $this->subject->getDirectories());
self::assertContains('dir2', $this->subject->getDirectories());
}

/**
Expand All @@ -50,7 +51,8 @@ public function setSymlinks(): void
{
$symlinks = ['toPath' => 'symlink1'];
$this->subject->setSymlinks($symlinks);
$this->assertSame($this->subject->getSymlinks(), $symlinks);

self::assertSame($this->subject->getSymlinks(), $symlinks);
}

/**
Expand All @@ -60,7 +62,8 @@ public function setDirectories(): void
{
$directories = ['dir1', 'dir2'];
$this->subject->setDirectories($directories);
$this->assertSame($this->subject->getDirectories(), $directories);

self::assertSame($this->subject->getDirectories(), $directories);
}

/**
Expand All @@ -72,6 +75,7 @@ public function registerTasksForGitTransferMethod(): void

$workflow->addTask(GitCheckoutTask::class, 'transfer', $this->subject)->shouldBeCalledOnce();
$deployment = $this->prophesize(Deployment::class);

$this->subject->setOption('transferMethod', 'git');
$this->subject->registerTasks($workflow->reveal(), $deployment->reveal());
}
Expand All @@ -85,6 +89,7 @@ public function registerTasksForScpTransferMethod(): void

$workflow->addTask(ScpTask::class, 'transfer', $this->subject)->shouldBeCalledOnce();
$deployment = $this->prophesize(Deployment::class);

$this->subject->setOption('transferMethod', 'scp');
$this->subject->registerTasks($workflow->reveal(), $deployment->reveal());
}
Expand All @@ -95,7 +100,8 @@ public function registerTasksForScpTransferMethod(): void
public function addSymlink(): void
{
$this->subject->addSymlink('toPath', 'fromPath');
$this->assertContains('fromPath', $this->subject->getSymlinks());

self::assertContains('fromPath', $this->subject->getSymlinks());
}

/**
Expand All @@ -105,7 +111,8 @@ public function addSymlinks(): void
{
$symlinks = ['toPath' => 'fromPath'];
$this->subject->addSymlinks($symlinks);
$this->assertContains('fromPath', $this->subject->getSymlinks());

self::assertContains('fromPath', $this->subject->getSymlinks());
}

/**
Expand All @@ -114,7 +121,7 @@ public function addSymlinks(): void
public function addDirectory(): void
{
$this->subject->addDirectory('toPath');
$this->assertContains('toPath', $this->subject->getDirectories());
self::assertContains('toPath', $this->subject->getDirectories());
}

/**
Expand Down
64 changes: 32 additions & 32 deletions tests/Unit/Application/Neos/FlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,7 @@ class FlowTest extends TestCase
*/
protected $subject;

public function commandPackageKeyProvider(): array
{
return [
['2.0', 'typo3.flow'],
['3.8', 'typo3.flow'],
['4.0', 'neos.flow'],
];
}

public function flowScriptNameProvider(): array
{
return [
['1.0', 'flow3'],
['1.1', 'flow3'],
['1.2', 'flow']
];
}

public function essentialsDirectoryNameProvider(): array
{
return [
['1.0', 'Common'],
['1.1', 'Common'],
['1.2', 'BuildEssentials']
];
}

protected function setUp()
protected function setUp(): void
{
$this->subject = new Flow();
}
Expand All @@ -62,7 +35,7 @@ protected function setUp()
public function getCommandPackageKey(string $version, string $expectedCommandPackageKey): void
{
$this->subject->setVersion($version);
$this->assertEquals($expectedCommandPackageKey, $this->subject->getCommandPackageKey());
self::assertEquals($expectedCommandPackageKey, $this->subject->getCommandPackageKey());
}

/**
Expand All @@ -72,7 +45,7 @@ public function getCommandPackageKey(string $version, string $expectedCommandPac
public function getBuildEssentialsDirectoryName(string $version, string $expectedEssentialsDirectoryName): void
{
$this->subject->setVersion($version);
$this->assertEquals($expectedEssentialsDirectoryName, $this->subject->getBuildEssentialsDirectoryName());
self::assertEquals($expectedEssentialsDirectoryName, $this->subject->getBuildEssentialsDirectoryName());
}

/**
Expand All @@ -82,7 +55,7 @@ public function getBuildEssentialsDirectoryName(string $version, string $expecte
public function getFlowScriptName(string $version, string $expectedFlowScriptName): void
{
$this->subject->setVersion($version);
$this->assertEquals($expectedFlowScriptName, $this->subject->getFlowScriptName());
self::assertEquals($expectedFlowScriptName, $this->subject->getFlowScriptName());
}

/**
Expand All @@ -95,6 +68,33 @@ public function registerComposerInstallTask(): void
$this->subject->setOption('updateMethod', 'composer');
$this->subject->registerTasks($workflow, $deployment->reveal());
$tasks = $workflow->getTasks();
$this->assertContains(InstallTask::class, $tasks['stage'][$this->subject->getName()]['update']['tasks']);
self::assertContains(InstallTask::class, $tasks['stage'][$this->subject->getName()]['update']['tasks']);
}

public function commandPackageKeyProvider(): array
{
return [
['2.0', 'typo3.flow'],
['3.8', 'typo3.flow'],
['4.0', 'neos.flow'],
];
}

public function flowScriptNameProvider(): array
{
return [
['1.0', 'flow3'],
['1.1', 'flow3'],
['1.2', 'flow']
];
}

public function essentialsDirectoryNameProvider(): array
{
return [
['1.0', 'Common'],
['1.1', 'Common'],
['1.2', 'BuildEssentials']
];
}
}
7 changes: 5 additions & 2 deletions tests/Unit/Application/TYPO3/CMSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CMSTest extends TestCase
*/
protected $subject;

protected function setUp()
protected function setUp(): void
{
$this->subject = new CMS();
}
Expand All @@ -34,15 +34,18 @@ protected function setUp()
public function setContextSuccessfully(): void
{
$this->subject->setContext('Production');
$this->assertSame($this->subject->getContext(), 'Production');
self::assertSame($this->subject->getContext(), 'Production');
}

/**
* @test
*/
public function registerTasks(): void
{
/* @var Deployment|\Prophecy\Prophecy\ObjectProphecy $workflow */
$deployment = $this->prophesize(Deployment::class);

/* @var Workflow|\Prophecy\Prophecy\ObjectProphecy $workflow */
$workflow = $this->prophesize(Workflow::class);
$workflow->addTask(Argument::any(), Argument::any(), $this->subject)->will(new FluidPromise());
$workflow->afterTask(Argument::any(), Argument::any(), $this->subject)->will(new FluidPromise());
Expand Down
6 changes: 2 additions & 4 deletions tests/Unit/AssertCommandExecuted.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ protected function matches($other): bool
if (preg_match($this->expectedCommand, $command)) {
return true;
}
} else {
if (strpos($command, $this->expectedCommand) !== false) {
return true;
}
} elseif (strpos($command, $this->expectedCommand) !== false) {
return true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Cli/Symfony/ConsoleOutputFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class ConsoleOutputFactoryTest extends TestCase
public function createOutput(): void
{
$consoleOutputFactory = new ConsoleOutputFactory();
$this->assertInstanceOf(ConsoleOutput::class, $consoleOutputFactory->createOutput());
self::assertInstanceOf(ConsoleOutput::class, $consoleOutputFactory->createOutput());
}
}
28 changes: 14 additions & 14 deletions tests/Unit/Cli/Symfony/Logger/ConsoleFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ class ConsoleFormatterTest extends TestCase
*/
protected $subject;

protected function setUp(): void
{
$this->subject = new ConsoleFormatter();
}

/**
* @test
* @dataProvider records
*/
public function format(array $record, string $expectedOutput): void
{
self::assertEquals($expectedOutput, $this->subject->format($record));
}

public function records(): array
{
return [
Expand Down Expand Up @@ -57,18 +71,4 @@ public function records(): array
],
];
}

protected function setUp()
{
$this->subject = new ConsoleFormatter();
}

/**
* @test
* @dataProvider records
*/
public function format(array $record, string $expectedOutput): void
{
$this->assertEquals($expectedOutput, $this->subject->format($record));
}
}
16 changes: 12 additions & 4 deletions tests/Unit/Cli/Symfony/Logger/ConsoleHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,48 @@ class ConsoleHandlerTest extends TestCase
*/
public function constructor(): void
{
/* @var OutputInterface|\Prophecy\Prophecy\ObjectProphecy $output */
$output = $this->prophesize(OutputInterface::class);

$handler = new ConsoleHandler($output->reveal(), false);
$this->assertFalse($handler->getBubble(), 'the bubble parameter gets propagated');
self::assertFalse($handler->getBubble(), 'the bubble parameter gets propagated');
}

/**
* @test
*/
public function isHandlingReturnsTrue(): void
{
/* @var OutputInterface|\Prophecy\Prophecy\ObjectProphecy $output */
$output = $this->prophesize(OutputInterface::class);
$output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_DEBUG)->shouldBeCalled();

$handler = new ConsoleHandler($output->reveal());
$this->assertTrue($handler->isHandling(['level' => Logger::ERROR]));
self::assertTrue($handler->isHandling(['level' => Logger::ERROR]));
}

/**
* @test
*/
public function isHandlingReturnsFalseIfOutputIsQuiet(): void
{
/* @var OutputInterface|\Prophecy\Prophecy\ObjectProphecy $output */
$output = $this->prophesize(OutputInterface::class);
$output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_QUIET)->shouldBeCalled();

$handler = new ConsoleHandler($output->reveal());
$this->assertFalse($handler->isHandling(['level' => Logger::ERROR]));
self::assertFalse($handler->isHandling(['level' => Logger::ERROR]));
}

/**
* @test
*/
public function getFormatter(): void
{
/* @var OutputInterface|\Prophecy\Prophecy\ObjectProphecy $output */
$output = $this->prophesize(OutputInterface::class);

$handler = new ConsoleHandler($output->reveal());
$this->assertInstanceOf(ConsoleFormatter::class, $handler->getFormatter());
self::assertInstanceOf(ConsoleFormatter::class, $handler->getFormatter());
}
}
4 changes: 3 additions & 1 deletion tests/Unit/Cli/Symfony/Logger/LoggerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class LoggerFactoryTest extends TestCase
*/
public function createLogger(): void
{
/* @var ConsoleHandler|\Prophecy\Prophecy\ObjectProphecy $output */
$consoleHandler = $this->prophesize(ConsoleHandler::class);

$loggerFactory = new LoggerFactory($consoleHandler->reveal());

$this->assertInstanceOf(Logger::class, $loggerFactory->createLogger());
self::assertInstanceOf(Logger::class, $loggerFactory->createLogger());
}
}
13 changes: 10 additions & 3 deletions tests/Unit/Command/DeployCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

final class DeployCommandTest extends TestCase
{

/**
* @var DeployCommand
*/
Expand All @@ -30,7 +29,7 @@ final class DeployCommandTest extends TestCase
*/
private $factory;

protected function setUp()
protected function setUp(): void
{
$this->factory = $this->prophesize(FactoryInterface::class);
$this->subject = new DeployCommand($this->factory->reveal());
Expand All @@ -41,10 +40,18 @@ protected function setUp()
*/
public function executeForceRun(): void
{
/* @var Deployment|\Prophecy\Prophecy\ObjectProphecy $deployment */
$deployment = $this->prophesize(Deployment::class);
$deployment->deploy()->shouldBeCalledOnce();
$deployment->getStatus()->willReturn(Deployment::STATUS_SUCCESS);
$this->factory->getDeployment('Foo', Argument::exact(null), Argument::exact(false), Argument::exact(true), Argument::exact(true))->willReturn($deployment);

$this->factory->getDeployment(
'Foo',
Argument::exact(null),
Argument::exact(false),
Argument::exact(true),
Argument::exact(true)
)->willReturn($deployment);

$commandTester = new CommandTester($this->subject);
$commandTester->execute([
Expand Down

0 comments on commit bf6cc51

Please sign in to comment.