Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing test for change made in #29 #30

Merged
merged 1 commit into from
Jun 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 20 additions & 38 deletions tests/Deserializers/DataValueDeserializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
use DataValues\Deserializers\DataValueDeserializer;
use DataValues\NumberValue;
use DataValues\StringValue;
use Deserializers\Exceptions\DeserializationException;
use Deserializers\Exceptions\MissingAttributeException;
use Deserializers\Exceptions\MissingTypeException;
use Deserializers\Exceptions\UnsupportedTypeException;
use InvalidArgumentException;
use PHPUnit_Framework_TestCase;

/**
Expand Down Expand Up @@ -53,7 +58,7 @@ public function notAnArrayProvider() {
* @dataProvider notADataValuesListProvider
*/
public function testGivenNonDataValues_constructorThrowsException( array $invalidDVList ) {
$this->setExpectedException( 'InvalidArgumentException' );
$this->setExpectedException( InvalidArgumentException::class );

new DataValueDeserializer( $invalidDVList );
}
Expand Down Expand Up @@ -92,14 +97,14 @@ public function notADataValuesListProvider() {
public function testGivenSerializationNoType_deserializeThrowsException() {
$deserializer = $this->newDeserializer();

$this->setExpectedException( 'Deserializers\Exceptions\MissingTypeException' );
$this->setExpectedException( MissingTypeException::class );
$deserializer->deserialize( array() );
}

public function testGivenSerializationWithUnknownType_deserializeThrowsException() {
$deserializer = $this->newDeserializer();

$this->setExpectedException( 'Deserializers\Exceptions\UnsupportedTypeException' );
$this->setExpectedException( UnsupportedTypeException::class );
$deserializer->deserialize(
array(
'type' => 'ohi'
Expand All @@ -110,7 +115,7 @@ public function testGivenSerializationWithUnknownType_deserializeThrowsException
public function testGivenSerializationWithNoValue_deserializeThrowsException() {
$deserializer = $this->newDeserializer();

$this->setExpectedException( 'Deserializers\Exceptions\MissingAttributeException' );
$this->setExpectedException( MissingAttributeException::class );
$deserializer->deserialize(
array(
'type' => 'number'
Expand All @@ -124,43 +129,20 @@ public function testGivenSerializationWithNoValue_deserializeThrowsException() {
public function testGivenInvalidDataValue_deserializeThrowsException( $invalidSerialization ) {
$deserializer = $this->newDeserializer();

$this->setExpectedException( 'Deserializers\Exceptions\DeserializationException' );
$this->setExpectedException( DeserializationException::class );
$deserializer->deserialize( $invalidSerialization );
}

public function invalidDataValueSerializationProvider() {
return array(
array(
'foo'
),

array(
null
),

array(
array()
),

array(
array(
'hax'
)
),

array(
array(
'type' => 'hax'
)
),

array(
array(
'type' => 'number',
'value' => array()
)
),
);
return [
[ 'foo' ],
[ null ],
[ [] ],
[ [ 'hax' ] ],
[ [ 'type' => 'hax' ] ],
[ [ 'type' => 'number', 'value' => [] ] ],
[ [ 'type' => 'boolean', 'value' => 'not a boolean' ] ],
];
}

public function testInvalidValueSerialization_throwsDeserializationException() {
Expand All @@ -171,7 +153,7 @@ public function testInvalidValueSerialization_throwsDeserializationException() {
);

$deserializer = $this->newDeserializer();
$this->setExpectedException( 'Deserializers\Exceptions\DeserializationException' );
$this->setExpectedException( DeserializationException::class );
$deserializer->deserialize( $serialization );
}

Expand Down