Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Jan 18, 2021
1 parent 1b24297 commit 0025331
Showing 1 changed file with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Tools\Console\Command;

use Doctrine\DBAL\Connection;
Expand All @@ -8,13 +10,16 @@
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\Tests\OrmTestCase;
use RuntimeException;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Tester\CommandTester;

use function array_merge;

class EnsureProductionSettingsCommandTest extends OrmTestCase
{
public function testExecute()
public function testExecute(): void
{
$em = $this->createMock(EntityManagerInterface::class);

Expand All @@ -31,14 +36,14 @@ public function testExecute()
$this->assertSame(0, $this->executeCommand($em));
}

public function testExecuteFailed()
public function testExecuteFailed(): void
{
$em = $this->createMock(EntityManagerInterface::class);

$configuration = $this->createMock(Configuration::class);
$configuration->expects($this->once())
->method('ensureProductionSettings')
->willThrowException(new \RuntimeException());
->willThrowException(new RuntimeException());

$em->method('getConfiguration')
->willReturn($configuration);
Expand All @@ -49,7 +54,7 @@ public function testExecuteFailed()
$this->assertSame(1, $this->executeCommand($em));
}

public function testExecuteWithComplete()
public function testExecuteWithComplete(): void
{
$em = $this->createMock(EntityManagerInterface::class);

Expand All @@ -71,6 +76,29 @@ public function testExecuteWithComplete()
$this->assertSame(0, $this->executeCommand($em, ['--complete' => true]));
}

public function testExecuteWithCompleteFailed(): void
{
$em = $this->createMock(EntityManagerInterface::class);

$configuration = $this->createMock(Configuration::class);
$configuration->expects($this->once())
->method('ensureProductionSettings');

$em->method('getConfiguration')
->willReturn($configuration);

$connection = $this->createMock(Connection::class);

$connection->expects($this->once())
->method('connect')
->willThrowException(new RuntimeException());

$em->method('getConnection')
->willReturn($connection);

$this->assertSame(1, $this->executeCommand($em, ['--complete' => true]));
}

/**
* @param mixed[] $options
*/
Expand All @@ -86,9 +114,9 @@ private function executeCommand(
$tester = new CommandTester($command);

return $tester->execute(
\array_merge([
array_merge([
'command' => $command->getName(),
], $input),
], $input)
);
}
}

0 comments on commit 0025331

Please sign in to comment.