-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
floriansemm
committed
Nov 3, 2016
1 parent
9108d15
commit 551e509
Showing
4 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
|
||
namespace FS\SolrBundle\Tests\Doctrine\Hydration; | ||
|
||
|
||
use FS\SolrBundle\Doctrine\Annotation\Field; | ||
use FS\SolrBundle\Doctrine\Hydration\DoctrineValueHydrator; | ||
use FS\SolrBundle\Doctrine\Mapper\MetaInformation; | ||
|
||
class DoctrineValueHydratorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function skipArrays() | ||
{ | ||
$hydrator = new DoctrineValueHydrator(); | ||
|
||
$this->assertFalse($hydrator->mapValue('createdAt', array(), new MetaInformation())); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function skipObjects() | ||
{ | ||
$hydrator = new DoctrineValueHydrator(); | ||
|
||
$field = new Field(array('type' => 'datetime')); | ||
$field->name = 'createdAt'; | ||
$field->getter = 'format(\'Y-m-d\TH:i:s.z\Z\')'; | ||
|
||
$metaInformation = new MetaInformation(); | ||
$metaInformation->setFields(array($field)); | ||
|
||
$this->assertFalse($hydrator->mapValue('createdAt', new \DateTime(), $metaInformation)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function mapCommonType() | ||
{ | ||
$hydrator = new DoctrineValueHydrator(); | ||
|
||
$field = new Field(array('type' => 'string')); | ||
$field->name = 'title'; | ||
|
||
$metaInformation = new MetaInformation(); | ||
$metaInformation->setFields(array($field)); | ||
|
||
$this->assertTrue($hydrator->mapValue('title_s', 'a title', $metaInformation)); | ||
} | ||
} |