|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Potherca\PhpUnit\Traits; |
| 4 | + |
| 5 | +use Potherca\PhpUnit\AbstractTestCase; |
| 6 | + |
| 7 | +/** |
| 8 | + * Test for the GetCompatibleExceptionNameTrait |
| 9 | + * |
| 10 | + * !!! Please make EXTRA sure no functionality from this library is used in tests !!! |
| 11 | + * |
| 12 | + * @requires PHP 5.4 |
| 13 | + * @coversDefaultClass \Potherca\PhpUnit\Traits\GetCompatibleExceptionNameTrait |
| 14 | + */ |
| 15 | +class GetCompatibleExceptionNameTraitTest extends AbstractTestCase |
| 16 | +{ |
| 17 | + /////////////////////////////////// TESTS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ |
| 18 | + |
| 19 | + /** |
| 20 | + * @covers ::getCompatibleExceptionName |
| 21 | + */ |
| 22 | + final public function testTraitShouldComplainWhenNotGivenExceptionName() |
| 23 | + { |
| 24 | + $trait = $this->getMockForTrait('\\Potherca\\PhpUnit\\Traits\\GetCompatibleExceptionNameTrait'); |
| 25 | + |
| 26 | + list($function, $expectedException, $expectedExceptionMessage) = $this->createMissingArgumentExpectation(1); |
| 27 | + |
| 28 | + $this->{$function}($expectedException, $expectedExceptionMessage); |
| 29 | + |
| 30 | + /** @noinspection PhpUndefinedMethodInspection */ |
| 31 | + $trait->getCompatibleExceptionName(); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * @covers ::getCompatibleExceptionName |
| 36 | + * |
| 37 | + * @uses \Potherca\PhpUnit\Shim\AbstractTraitShim |
| 38 | + * @uses \Potherca\PhpUnit\Shim\Util |
| 39 | + */ |
| 40 | + final public function testTraitShouldCallUtilShimWhenGivenExceptionName() |
| 41 | + { |
| 42 | + $trait = $this->getMockForTrait('\\Potherca\\PhpUnit\\Traits\\GetCompatibleExceptionNameTrait'); |
| 43 | + |
| 44 | + $expectedException = '\\Potherca\\PhpUnit\\InvalidArgumentException'; |
| 45 | + $expectedExceptionMessage = 'Argument 1 passed to Potherca\PhpUnit\Shim\AbstractTraitShim::__construct must be an instance of "\PHPUnit_Framework_TestCase" or "\PHPUnit\Framework\TestCase", Mock_Trait_GetCompatibleExceptionNameTrait'; |
| 46 | + |
| 47 | + $function = $this->getExpectExpectationMethodName(); |
| 48 | + |
| 49 | + $this->{$function}($expectedException, $expectedExceptionMessage); |
| 50 | + |
| 51 | + $trait->getCompatibleExceptionName('Mock Exception Name'); |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +/*EOF*/ |
0 commit comments