| @@ 642-663 (lines=22) @@ | ||
| 639 | * |
|
| 640 | * @dataProvider provideInputForToHash |
|
| 641 | */ |
|
| 642 | public function testToHash($inputValue, $expectedResult) |
|
| 643 | { |
|
| 644 | $fieldType = $this->getFieldTypeUnderTest(); |
|
| 645 | ||
| 646 | $actualResult = $fieldType->toHash($inputValue); |
|
| 647 | ||
| 648 | $this->assertIsValidHashValue($actualResult); |
|
| 649 | ||
| 650 | if (is_object($expectedResult) || is_array($expectedResult)) { |
|
| 651 | $this->assertEquals( |
|
| 652 | $expectedResult, |
|
| 653 | $actualResult, |
|
| 654 | 'toHash() method did not create expected result.' |
|
| 655 | ); |
|
| 656 | } else { |
|
| 657 | $this->assertSame( |
|
| 658 | $expectedResult, |
|
| 659 | $actualResult, |
|
| 660 | 'toHash() method did not create expected result.' |
|
| 661 | ); |
|
| 662 | } |
|
| 663 | } |
|
| 664 | ||
| 665 | /** |
|
| 666 | * @param mixed $inputValue |
|
| @@ 671-692 (lines=22) @@ | ||
| 668 | * |
|
| 669 | * @dataProvider provideInputForFromHash |
|
| 670 | */ |
|
| 671 | public function testFromHash($inputHash, $expectedResult) |
|
| 672 | { |
|
| 673 | $this->assertIsValidHashValue($inputHash); |
|
| 674 | ||
| 675 | $fieldType = $this->getFieldTypeUnderTest(); |
|
| 676 | ||
| 677 | $actualResult = $fieldType->fromHash($inputHash); |
|
| 678 | ||
| 679 | if (is_object($expectedResult) || is_array($expectedResult)) { |
|
| 680 | $this->assertEquals( |
|
| 681 | $expectedResult, |
|
| 682 | $actualResult, |
|
| 683 | 'fromHash() method did not create expected result.' |
|
| 684 | ); |
|
| 685 | } else { |
|
| 686 | $this->assertSame( |
|
| 687 | $expectedResult, |
|
| 688 | $actualResult, |
|
| 689 | 'fromHash() method did not create expected result.' |
|
| 690 | ); |
|
| 691 | } |
|
| 692 | } |
|
| 693 | ||
| 694 | public function testEmptyValueIsEmpty() |
|
| 695 | { |
|