testConstructorWithOnlyRequiredArguments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Deserializers\Tests\Phpunit\Exceptions;
4
5
use Deserializers\Exceptions\InvalidAttributeException;
6
use Exception;
7
8
/**
9
 * @covers Deserializers\Exceptions\InvalidAttributeException
10
 *
11
 * @license GPL-2.0-or-later
12
 * @author Jeroen De Dauw < [email protected] >
13
 * @author Thiemo Kreuz
14
 */
15
class InvalidAttributeExceptionTest extends \PHPUnit\Framework\TestCase {
16
17
	public function testConstructorWithOnlyRequiredArguments() {
18
		$exception = new InvalidAttributeException( 'attribute', 'value' );
19
20
		$this->assertSame( 'attribute', $exception->getAttributeName() );
21
		$this->assertSame( 'value', $exception->getAttributeValue() );
22
		$this->assertSame( 'Attribute "attribute" with value "value" is invalid',
23
			$exception->getMessage() );
24
		$this->assertNull( $exception->getPrevious() );
25
	}
26
27
	public function testConstructorWithAllArguments() {
28
		$previous = new Exception( 'previous' );
29
		$exception = new InvalidAttributeException( 'attribute', 'value', 'customMessage',
30
			$previous );
31
32
		$this->assertSame( 'attribute', $exception->getAttributeName() );
33
		$this->assertSame( 'value', $exception->getAttributeValue() );
34
		$this->assertSame( 'customMessage', $exception->getMessage() );
35
		$this->assertSame( $previous, $exception->getPrevious() );
36
	}
37
38
}
39