Skip to content

Commit

Permalink
Add tests for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Mar 29, 2021
1 parent b284a31 commit dc29a61
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/Exception/Cli/InvalidArgumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Test the InvalidArgument exception.
*
* @covers \AmpProject\Exception\InvalidArgument
* @covers \AmpProject\Exception\Cli\InvalidArgument
* @package ampproject/amp-toolbox
*/
class InvalidArgumentTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/Cli/InvalidColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Test the InvalidColor exception.
*
* @covers \AmpProject\Exception\InvalidColor
* @covers \AmpProject\Exception\Cli\InvalidColor
* @package ampproject/amp-toolbox
*/
class InvalidColorTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/Cli/InvalidColumnFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Test the InvalidColumnFormat exception.
*
* @covers \AmpProject\Exception\InvalidColumnFormat
* @covers \AmpProject\Exception\Cli\InvalidColumnFormat
* @package ampproject/amp-toolbox
*/
class InvalidColumnFormatTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/Cli/InvalidCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Test the InvalidCommand exception.
*
* @covers \AmpProject\Exception\InvalidCommand
* @covers \AmpProject\Exception\Cli\InvalidCommand
* @package ampproject/amp-toolbox
*/
class InvalidCommandTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/Cli/InvalidOptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Test the InvalidOption exception.
*
* @covers \AmpProject\Exception\InvalidOption
* @covers \AmpProject\Exception\Cli\InvalidOption
* @package ampproject/amp-toolbox
*/
class InvalidOptionTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/Cli/InvalidSapiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Test the InvalidSapi exception.
*
* @covers \AmpProject\Exception\InvalidSapi
* @covers \AmpProject\Exception\Cli\InvalidSapi
* @package ampproject/amp-toolbox
*/
class InvalidSapiTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/Cli/MissingArgumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Test the MissingArgument exception.
*
* @covers \AmpProject\Exception\MissingArgument
* @covers \AmpProject\Exception\Cli\MissingArgument
* @package ampproject/amp-toolbox
*/
class MissingArgumentTest extends TestCase
Expand Down
26 changes: 26 additions & 0 deletions tests/Exception/InvalidAttributeNameTest.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 InvalidAttributeName exception.
*
* @covers \AmpProject\Exception\InvalidAttributeName
* @package ampproject/amp-toolbox
*/
class InvalidAttributeNameTest extends TestCase
{

/**
* Test throwing the exception for an attribute.
*/
public function testThrowingForAttribute()
{
$this->expectException(InvalidAttributeName::class);
$this->expectExceptionMessage("Invalid attribute 'attributeName' was requested from the validator spec.");

throw InvalidAttributeName::forAttribute('attributeName');
}
}
26 changes: 26 additions & 0 deletions tests/Exception/InvalidCssNameTest.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 InvalidCssName exception.
*
* @covers \AmpProject\Exception\InvalidCssName
* @package ampproject/amp-toolbox
*/
class InvalidCssNameTest extends TestCase
{

/**
* Test throwing the exception for a CSS name.
*/
public function testThrowingForCssName()
{
$this->expectException(InvalidCssName::class);
$this->expectExceptionMessage("Invalid css name 'cssName' was requested from the validator spec.");

throw InvalidCssName::forCssName('cssName');
}
}
26 changes: 26 additions & 0 deletions tests/Exception/InvalidExtensionTest.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 InvalidExtension exception.
*
* @covers \AmpProject\Exception\InvalidExtension
* @package ampproject/amp-toolbox
*/
class InvalidExtensionTest extends TestCase
{

/**
* Test throwing the exception for an extension.
*/
public function testThrowingForExtension()
{
$this->expectException(InvalidExtension::class);
$this->expectExceptionMessage("Invalid extension 'extensionName' was requested from the validator spec.");

throw InvalidExtension::forExtension('extensionName');
}
}
26 changes: 26 additions & 0 deletions tests/Exception/InvalidFormatTest.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 InvalidFormat exception.
*
* @covers \AmpProject\Exception\InvalidFormat
* @package ampproject/amp-toolbox
*/
class InvalidFormatTest extends TestCase
{

/**
* Test throwing the exception for an format.
*/
public function testThrowingForFormat()
{
$this->expectException(InvalidFormat::class);
$this->expectExceptionMessage("Invalid format 'formatName' was requested from the validator spec.");

throw InvalidFormat::forFormat('formatName');
}
}
41 changes: 41 additions & 0 deletions tests/Exception/InvalidListNameTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace AmpProject\Exception;

use AmpProject\Tests\TestCase;

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

/**
* Test throwing the exception for an attribute list.
*/
public function testThrowingForAttributeList()
{
$this->expectException(InvalidListName::class);
$this->expectExceptionMessage(
"Invalid attribute list 'attributeListName' was requested from the validator spec."
);

throw InvalidListName::forAttributeList('attributeListName');
}

/**
* Test throwing the exception for an declaration list.
*/
public function testThrowingForDeclarationList()
{
$this->expectException(InvalidListName::class);
$this->expectExceptionMessage(
"Invalid declaration list 'declarationListName' was requested from the validator spec."
);

throw InvalidListName::forDeclarationList('declarationListName');
}
}
26 changes: 26 additions & 0 deletions tests/Exception/InvalidSpecNameTest.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 InvalidSpecName exception.
*
* @covers \AmpProject\Exception\InvalidSpecName
* @package ampproject/amp-toolbox
*/
class InvalidSpecNameTest extends TestCase
{

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

throw InvalidSpecName::forSpecName('specName');
}
}
26 changes: 26 additions & 0 deletions tests/Exception/InvalidSpecRuleNameTest.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 InvalidSpecRuleName exception.
*
* @covers \AmpProject\Exception\InvalidSpecRuleName
* @package ampproject/amp-toolbox
*/
class InvalidSpecRuleNameTest extends TestCase
{

/**
* Test throwing the exception for a spec rule name.
*/
public function testThrowingForSpecRuleName()
{
$this->expectException(InvalidSpecRuleName::class);
$this->expectExceptionMessage("Invalid spec rule name 'specRuleName' was requested from the validator spec.");

throw InvalidSpecRuleName::forSpecRuleName('specRuleName');
}
}
26 changes: 26 additions & 0 deletions tests/Exception/InvalidTagIdTest.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 InvalidTagId exception.
*
* @covers \AmpProject\Exception\InvalidTagId
* @package ampproject/amp-toolbox
*/
class InvalidTagIdTest extends TestCase
{

/**
* Test throwing the exception for a tag ID.
*/
public function testThrowingForTagId()
{
$this->expectException(InvalidTagId::class);
$this->expectExceptionMessage("Invalid tag ID 'tagId' was requested from the validator tag.");

throw InvalidTagId::forTagId('tagId');
}
}

0 comments on commit dc29a61

Please sign in to comment.