mdiyakov /
DoctrineSolrBundle
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Mdiyakov\DoctrineSolrBundle\Tests\Schema\Field\Entity; |
||||
| 4 | |||||
| 5 | use Mdiyakov\DoctrineSolrBundle\Schema\Field\Entity\DoubleField; |
||||
| 6 | |||||
| 7 | class DoubleFieldTest extends \PHPUnit_Framework_TestCase |
||||
| 8 | { |
||||
| 9 | |||||
| 10 | public function testGetDocumentValueForNumbers() |
||||
| 11 | { |
||||
| 12 | $int = 123; |
||||
| 13 | $double = 123.83; |
||||
| 14 | |||||
| 15 | $entity = new \stdClass(); |
||||
| 16 | $field = new DoubleField('price', 'd_price', false, 10, false); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 17 | |||||
| 18 | $entity->price = $double; |
||||
| 19 | $fieldValue = $field->getDocumentFieldValue($entity); |
||||
| 20 | $this->assertEquals(123.83 ,$fieldValue); |
||||
| 21 | |||||
| 22 | $entity->price = $int; |
||||
| 23 | $fieldValue = $field->getDocumentFieldValue($entity); |
||||
| 24 | $this->assertEquals(123.00 ,$fieldValue); |
||||
| 25 | |||||
| 26 | } |
||||
| 27 | |||||
| 28 | /** |
||||
| 29 | * @dataProvider notNumberProvider |
||||
| 30 | * @expectedException \Mdiyakov\DoctrineSolrBundle\Exception\InvalidFieldValueException |
||||
| 31 | */ |
||||
| 32 | public function testGetDocumentValueForNotNumber($value) |
||||
| 33 | { |
||||
| 34 | $entity = new \stdClass(); |
||||
| 35 | $field = new DoubleField('price', 'd_price', false, 10, false); |
||||
|
0 ignored issues
–
show
false of type false is incompatible with the type string expected by parameter $suggester of Mdiyakov\DoctrineSolrBun...bleField::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 36 | |||||
| 37 | $entity->price = $value; |
||||
| 38 | $field->getDocumentFieldValue($entity); |
||||
| 39 | } |
||||
| 40 | |||||
| 41 | /** |
||||
| 42 | * @return array |
||||
| 43 | */ |
||||
| 44 | public function notNumberProvider() |
||||
| 45 | { |
||||
| 46 | return [ |
||||
| 47 | ['urytryry453'], |
||||
| 48 | [true], |
||||
| 49 | [new \stdClass()] |
||||
| 50 | ]; |
||||
| 51 | } |
||||
| 52 | } |