Skip to content

Commit 5ed1082

Browse files
committed
Add helpers to assert exception was thrown
1 parent 3f2878a commit 5ed1082

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/framework/tests/Feature/YamlConfigurationFeatureTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ public function testCanSetAuthorsInTheYamlConfig()
456456

457457
public function testTypeErrorsInAuthorsYamlConfigAreRethrownMoreHelpfully()
458458
{
459+
$exceptionThrown = false;
460+
459461
file_put_contents('hyde.yml', <<<'YAML'
460462
authors:
461463
wrong:
@@ -465,9 +467,11 @@ public function testTypeErrorsInAuthorsYamlConfigAreRethrownMoreHelpfully()
465467
try {
466468
$this->runBootstrappers();
467469
} catch (InvalidConfigurationException $exception) {
470+
$exceptionThrown = true;
468471
$this->assertSame('Invalid author configuration detected in the YAML config file. Please double check the syntax.', $exception->getMessage());
469472
}
470473

474+
$this->assertTrue($exceptionThrown);
471475
unlink('hyde.yml');
472476
}
473477

@@ -660,6 +664,8 @@ public function testNavigationItemsInTheYamlConfigCanBeResolvedToRoutes()
660664

661665
public function testTypeErrorsInNavigationYamlConfigAreRethrownMoreHelpfully()
662666
{
667+
$exceptionThrown = false;
668+
663669
file_put_contents('hyde.yml', <<<'YAML'
664670
hyde:
665671
navigation:
@@ -670,14 +676,18 @@ public function testTypeErrorsInNavigationYamlConfigAreRethrownMoreHelpfully()
670676
try {
671677
$this->runBootstrappers();
672678
} catch (InvalidConfigurationException $exception) {
679+
$exceptionThrown = true;
673680
$this->assertSame('Invalid navigation item configuration detected the configuration file. Please double check the syntax.', $exception->getMessage());
674681
}
675682

683+
$this->assertTrue($exceptionThrown);
676684
unlink('hyde.yml');
677685
}
678686

679687
public function testMustAddDestinationToYamlConfiguredNavigationItems()
680688
{
689+
$exceptionThrown = false;
690+
681691
file_put_contents('hyde.yml', <<<'YAML'
682692
hyde:
683693
navigation:
@@ -688,14 +698,18 @@ public function testMustAddDestinationToYamlConfiguredNavigationItems()
688698
try {
689699
$this->runBootstrappers();
690700
} catch (InvalidConfigurationException $exception) {
701+
$exceptionThrown = true;
691702
$this->assertSame('Invalid navigation item configuration detected the configuration file. Please double check the syntax.', $exception->getMessage());
692703
}
693704

705+
$this->assertTrue($exceptionThrown);
694706
unlink('hyde.yml');
695707
}
696708

697709
public function testAddingExtraYamlNavigationItemFieldsThrowsAnException()
698710
{
711+
$exceptionThrown = false;
712+
699713
file_put_contents('hyde.yml', <<<'YAML'
700714
hyde:
701715
navigation:
@@ -707,9 +721,11 @@ public function testAddingExtraYamlNavigationItemFieldsThrowsAnException()
707721
try {
708722
$this->runBootstrappers();
709723
} catch (InvalidConfigurationException $exception) {
724+
$exceptionThrown = true;
710725
$this->assertSame('Invalid navigation item configuration detected the configuration file. Please double check the syntax.', $exception->getMessage());
711726
}
712727

728+
$this->assertTrue($exceptionThrown);
713729
unlink('hyde.yml');
714730
}
715731

0 commit comments

Comments
 (0)