Skip to content

Commit

Permalink
Fix DecimalValueTest::testTrailingNewlineRobustness()
Browse files Browse the repository at this point in the history
This test isn’t supposed to be a test for serialization stability, so
instead of asserting that the value’s serialization is identical to a
hard-coded string, assert that the value is equal to the deserialization
of a hard-coded string.
  • Loading branch information
lucaswerkmeister committed Oct 14, 2022
1 parent 6451d8a commit 38f2f48
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/DataValues/DecimalValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ public function testTrailingNewlineRobustness() {
$value = DecimalValue::newFromArray( "-0.0\n" );

$this->assertTrue( $value->isZero() );
$this->assertSame( 'C:23:"DataValues\DecimalValue":11:{s:4:"+0.0";}', serialize( $value ) );
$this->assertSame( '+0.0', $value->getValue(), 'getValue' );
$this->assertSame( '+0.0', $value->getArrayValue(), 'getArrayValue' );
$this->assertSame( '+0.0', $value->__toString(), '__toString' );
$this->assertSame( '0', $value->getFractionalPart(), 'getFractionalPart' );

$referenceValue = unserialize( 'C:23:"DataValues\DecimalValue":11:{s:4:"+0.0";}' );
$this->assertTrue( $value->equals( $referenceValue ), 'equal to hard-coded serialization' );
}

/**
Expand Down

0 comments on commit 38f2f48

Please sign in to comment.