Skip to content

Commit

Permalink
Expecting exception when seeder template doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Firtzberg authored Jan 13, 2021
1 parent 6a5575c commit 9a241a2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/Phinx/Console/Command/SeedCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,12 @@ public function testAlternativeTemplateDoesntExist()

$commandTester = new CommandTester($command);

$commandLine = ['command' => $command->getName(), 'name' => 'AltTemplateDoesntExist', '--template' => __DIR__ . '/Templates/ThisDoesntExist.template.php.dist'];
$commandTester->execute($commandLine, ['decorated' => false]);
$template = __DIR__ . '/Templates/ThisDoesntExist.template.php.dist';
$commandLine = ['command' => $command->getName(), 'name' => 'AltTemplateDoesntExist', '--template' => $template];

// Get output.
preg_match('`The alternative template file "(?P<AltTemplate>.*?)" does not exist\s`', $commandTester->getDisplay(), $match);
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The alternative template file "' . $template . '" does not exist');

// Check reported file name
$this->assertEquals($match['AltTemplate'], $commandLine['--template']);
$commandTester->execute($commandLine, ['decorated' => false]);
}
}

0 comments on commit 9a241a2

Please sign in to comment.