Skip to content

Commit

Permalink
Moved tests to check that 'assertTemplateName' fails as intended when…
Browse files Browse the repository at this point in the history
… the template is not found and the 'assertNotTemplateName' fails when the template is found. to separate test cases.

Signed-off-by: Eric Richer [email protected] <[email protected]>
  • Loading branch information
visto9259 committed Sep 16, 2024
1 parent a7f952f commit 3a8099a
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions test/PHPUnit/Controller/AbstractControllerTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,28 +561,36 @@ public function testSearchTemplatesVerifiesDeeplyNestedTemplateName(): void
$this->assertTemplateName('child2');
$this->assertTemplateName('child3');
$this->assertNotTemplateName('foo');
}

/**
* Check that the assertion fails when template is NOT found where it was supposed to found
*/
public function testAssertTemplateNameFailsWhenNotFound(): void
{
$this->dispatch('/childview');

// Check that the test fails when template is NOT found where it was supposed to found
try {
$this->assertTemplateName('foo');
$receivedException = false;
} catch (Exception $exception) {
$receivedException = true;
}
if (! $receivedException) {
$this->fail('Expected Exception not thrown');
} catch (ExpectationFailedException $exception) {
return;
}
$this->fail('Expected Exception not thrown');
}

/**
* Check that the assertion fails when template is found where it was NOT supposed to found
*/
public function testAssertNotTemplateNameFailsWhenFound(): void
{
$this->dispatch('/childview');

// Check when template is found where it was NOT supposed to found
try {
$this->assertNotTemplateName('child1');
$receivedException = false;
} catch (Exception $exception) {
$receivedException = true;
}
if (! $receivedException) {
$this->fail('Expected Exception not thrown');
} catch (ExpectationFailedException $exception) {
return;
}
$this->fail('Expected Exception not thrown');
}

public function testCustomResponseObject(): void
Expand Down

0 comments on commit 3a8099a

Please sign in to comment.