| Total Complexity | 3 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class SplFloatTest extends TestCase |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Unit test. |
||
| 23 | * |
||
| 24 | * @return void |
||
| 25 | */ |
||
| 26 | public function test(): void |
||
| 27 | { |
||
| 28 | $instance = new DuckFloat(); |
||
| 29 | $this->assertSame(0.0, $instance()); |
||
| 30 | |||
| 31 | $instance = new DuckFloat(10.1); |
||
| 32 | $this->assertSame(10.1, $instance()); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Unit test. |
||
| 37 | * |
||
| 38 | * @return void |
||
| 39 | * |
||
| 40 | * @psalm-suppress UnsupportedReferenceUsage |
||
| 41 | */ |
||
| 42 | public function testMath(): void |
||
| 43 | { |
||
| 44 | $instance = new DuckFloat(10.1); |
||
| 45 | |||
| 46 | $value = &$instance(); |
||
| 47 | $value++; |
||
| 48 | |||
| 49 | $this->assertSame(11.1, $value); |
||
| 50 | $this->assertSame(11.1, $instance()); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Unit test. |
||
| 55 | * |
||
| 56 | * @return void |
||
| 57 | */ |
||
| 58 | public function testSerialization(): void |
||
| 59 | { |
||
| 60 | $instance = new DuckFloat(22.9); |
||
| 61 | $serialized = \serialize($instance); |
||
| 62 | $unserialized = \unserialize($serialized); |
||
| 63 | |||
| 64 | $this->assertEquals($instance, $unserialized); |
||
| 65 | $this->assertEquals(22.9, $instance()); |
||
| 66 | } |
||
| 68 |