UnsupportedObjectExceptionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithOnlyRequiredArguments() 0 7 1
A testConstructorWithAllArguments() 0 11 1
A assertRequiredFieldsAreSet() 0 3 1
1
<?php
2
3
namespace Serializers\Tests\Phpunit\Exceptions;
4
5
use Serializers\Exceptions\UnsupportedObjectException;
6
7
/**
8
 * @covers Serializers\Exceptions\UnsupportedObjectException
9
 *
10
 * @group Serialization
11
 *
12
 * @license GPL-2.0-or-later
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class UnsupportedObjectExceptionTest extends \PHPUnit\Framework\TestCase {
16
17
	public function testConstructorWithOnlyRequiredArguments() {
18
		$object = [ 'the' => 'game' ];
19
20
		$exception = new UnsupportedObjectException( $object );
21
22
		$this->assertRequiredFieldsAreSet( $exception, $object );
23
	}
24
25
	public function testConstructorWithAllArguments() {
26
		$object = [ 'the' => 'game' ];
27
		$message = 'NyanData all the way across the sky!';
28
		$previous = new \Exception( 'Onoez!' );
29
30
		$exception = new UnsupportedObjectException( $object, $message, $previous );
31
32
		$this->assertRequiredFieldsAreSet( $exception, $object );
33
		$this->assertEquals( $message, $exception->getMessage() );
34
		$this->assertEquals( $previous, $exception->getPrevious() );
35
	}
36
37
	private function assertRequiredFieldsAreSet( UnsupportedObjectException $exception, $object ) {
38
		$this->assertEquals( $object, $exception->getUnsupportedObject() );
39
	}
40
41
}
42