Skip to content

Commit

Permalink
Add missing exception tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed May 26, 2021
1 parent 131e2c4 commit ecb7398
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/Exception/InvalidDeclarationNametest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace AmpProject\Exception;

use AmpProject\Tests\TestCase;

/**
* Test the InvalidDeclarationName exception.
*
* @covers \AmpProject\Exception\InvalidDeclarationName
* @package ampproject/amp-toolbox
*/
class InvalidDeclarationNameTest extends TestCase
{

/**
* Test throwing the exception for an invalid declaration name.
*/
public function testThrowingForDeclarationName()
{
$this->expectException(InvalidDeclarationName::class);
$this->expectExceptionMessage(
"Invalid declaration name 'declarationName' was requested from the validator spec."
);

throw InvalidDeclarationName::forDeclaration('declarationName');
}
}
26 changes: 26 additions & 0 deletions tests/Exception/InvalidDocRulesetNameTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace AmpProject\Exception;

use AmpProject\Tests\TestCase;

/**
* Test the InvalidDocRulesetName exception.
*
* @covers \AmpProject\Exception\InvalidDocRulesetName
* @package ampproject/amp-toolbox
*/
class InvalidDocRulesetNameTest extends TestCase
{

/**
* Test throwing the exception for a document ruleset name.
*/
public function testThrowingForDocRulesetName()
{
$this->expectException(InvalidDocRulesetName::class);
$this->expectExceptionMessage("Invalid document ruleset name 'docName' was requested from the validator spec.");

throw InvalidDocRulesetName::forDocRulesetName('docName');
}
}

0 comments on commit ecb7398

Please sign in to comment.