| Total Complexity | 3 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class IntFieldTest extends \PHPUnit_Framework_TestCase |
||
| 8 | { |
||
| 9 | |||
| 10 | public function testGetDocumentValueForNumbers() |
||
| 11 | { |
||
| 12 | $int = 123; |
||
| 13 | $double = 123.83; |
||
| 14 | $null = null; |
||
| 15 | |||
| 16 | $entity = new \stdClass(); |
||
| 17 | $field = new IntField('price', 'd_price', false, 10, false); |
||
|
|
|||
| 18 | |||
| 19 | $entity->price = $double; |
||
| 20 | $fieldValue = $field->getDocumentFieldValue($entity); |
||
| 21 | $this->assertEquals(123,$fieldValue); |
||
| 22 | |||
| 23 | $entity->price = $int; |
||
| 24 | $fieldValue = $field->getDocumentFieldValue($entity); |
||
| 25 | $this->assertEquals(123,$fieldValue); |
||
| 26 | |||
| 27 | $entity->price = $null; |
||
| 28 | $fieldValue = $field->getDocumentFieldValue($entity); |
||
| 29 | $this->assertEquals(0,$fieldValue); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @dataProvider notNumberProvider |
||
| 34 | * @expectedException \Mdiyakov\DoctrineSolrBundle\Exception\InvalidFieldValueException |
||
| 35 | */ |
||
| 36 | public function testGetDocumentValueForNotNumber($value) |
||
| 37 | { |
||
| 38 | $entity = new \stdClass(); |
||
| 39 | $field = new IntField('price', 'd_price', false, 10, false); |
||
| 40 | |||
| 41 | $entity->price = $value; |
||
| 42 | $field->getDocumentFieldValue($entity); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @return array |
||
| 47 | */ |
||
| 48 | public function notNumberProvider() |
||
| 54 | ]; |
||
| 55 | } |
||
| 56 | } |