MissingAttributeExceptionTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithOnlyRequiredArguments() 0 7 1
A testConstructorWithAllArguments() 0 8 1
1
<?php
2
3
namespace Deserializers\Tests\Phpunit\Exceptions;
4
5
use Deserializers\Exceptions\MissingAttributeException;
6
use Exception;
7
8
/**
9
 * @covers Deserializers\Exceptions\MissingAttributeException
10
 *
11
 * @license GPL-2.0-or-later
12
 * @author Jeroen De Dauw < [email protected] >
13
 * @author Thiemo Kreuz
14
 */
15
class MissingAttributeExceptionTest extends \PHPUnit\Framework\TestCase {
16
17
	public function testConstructorWithOnlyRequiredArguments() {
18
		$exception = new MissingAttributeException( 'attribute' );
19
20
		$this->assertSame( 'attribute', $exception->getAttributeName() );
21
		$this->assertSame( 'Attribute "attribute" is missing', $exception->getMessage() );
22
		$this->assertNull( $exception->getPrevious() );
23
	}
24
25
	public function testConstructorWithAllArguments() {
26
		$previous = new Exception( 'previous' );
27
		$exception = new MissingAttributeException( 'attribute', 'customMessage', $previous );
28
29
		$this->assertSame( 'attribute', $exception->getAttributeName() );
30
		$this->assertSame( 'customMessage', $exception->getMessage() );
31
		$this->assertSame( $previous, $exception->getPrevious() );
32
	}
33
34
}
35