commit
bfbcdb4c21
|
@ -51,7 +51,6 @@ class MappingRegistry
|
|||
public function getTypeFieldNames(Elastica_Type $type)
|
||||
{
|
||||
$key = sprintf('%s/%s', $type->getIndex()->getName(), $type->getType());
|
||||
|
||||
if (!isset($this->mappings[$key])) {
|
||||
throw new InvalidArgumentException(sprintf('This type is not registered: "%s".', $key));
|
||||
}
|
||||
|
|
4
Populator.php
Normal file → Executable file
4
Populator.php
Normal file → Executable file
|
@ -11,7 +11,9 @@ class Populator
|
|||
|
||||
public function __construct(array $providers)
|
||||
{
|
||||
$this->providers = $providers;
|
||||
foreach ($providers as $name => $provider) {
|
||||
$this->addProvider($name, $provider);
|
||||
}
|
||||
}
|
||||
|
||||
public function addProvider($name, ProviderInterface $provider)
|
||||
|
|
42
Tests/IndexManagerTest.php
Normal file
42
Tests/IndexManagerTest.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Tests\IndexManager;
|
||||
|
||||
use FOQ\ElasticaBundle\IndexManager;
|
||||
|
||||
class IndexManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var FOQ\ElasticaBundle\Tests\IndexManager
|
||||
*/
|
||||
private $indexManager = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->indexManager = new IndexManager(array('index1' => 'test1', 'index2' => 'test2'), 'defaultIndex');
|
||||
}
|
||||
|
||||
public function testThatWeCanGetAllIndexes()
|
||||
{
|
||||
$this->assertEquals(array('index1' => 'test1', 'index2' => 'test2'), $this->indexManager->getAllIndexes());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testThatWeCannotGetIndexWhichWasNotSet()
|
||||
{
|
||||
$this->indexManager->getIndex('index8');
|
||||
}
|
||||
|
||||
public function testThatWeCanGetDefaultIndex()
|
||||
{
|
||||
$this->assertEquals('defaultIndex', $this->indexManager->getIndex(false));
|
||||
$this->assertEquals('defaultIndex', $this->indexManager->getDefaultIndex());
|
||||
}
|
||||
|
||||
public function testThatWeCanGetIndex()
|
||||
{
|
||||
$this->assertEquals('test2', $this->indexManager->getIndex('index2'));
|
||||
}
|
||||
}
|
91
Tests/MappingRegistryTest.php
Normal file
91
Tests/MappingRegistryTest.php
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Tests\MappingRegistry;
|
||||
|
||||
use FOQ\ElasticaBundle\MappingRegistry;
|
||||
use Elastica_Type;
|
||||
use Elastica_Index;
|
||||
|
||||
class MappingRegistryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (!class_exists('Elastica_Type') || !class_exists('Elastica_Index')) {
|
||||
$this->markTestSkipped('The Elastica library classes are not available');
|
||||
}
|
||||
}
|
||||
|
||||
public function testThatCanApplyMappings()
|
||||
{
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$typeMock->expects($this->once())
|
||||
->method('setMapping')
|
||||
->with($this->equalTo(array('mappingArray')));
|
||||
|
||||
$mapping = new MappingRegistry(array(
|
||||
'index/type' => array($typeMock, array('mappingArray'))
|
||||
));
|
||||
|
||||
$mapping->applyMappings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidTypesParametersProvider
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testThatCannotGetTypeFieldForTypeWhichNotExists($indexName, $typeName)
|
||||
{
|
||||
$type = $this->getTypeMock('index', 'type');
|
||||
$mapping = new MappingRegistry(array(
|
||||
'index/type' => array($type, array('mappingArray'))
|
||||
));
|
||||
|
||||
$mapping->getTypeFieldNames($this->getTypeMock($indexName, $typeName));
|
||||
}
|
||||
|
||||
public function testThatCanGetTypeField()
|
||||
{
|
||||
$type = $this->getTypeMock('index', 'type');
|
||||
$mapping = new MappingRegistry(array(
|
||||
'index/type' => array($type, array('mappingArray'))
|
||||
));
|
||||
|
||||
$mapping->getTypeFieldNames($this->getTypeMock('index', 'type'));
|
||||
}
|
||||
|
||||
public static function invalidTypesParametersProvider()
|
||||
{
|
||||
return array(
|
||||
array('index1', 'type'),
|
||||
array('index', 'type2')
|
||||
);
|
||||
}
|
||||
|
||||
private function getTypeMock($indexName, $typeName)
|
||||
{
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$indexMock = $this->getMockBuilder('Elastica_Index')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$indexMock->expects($this->any())
|
||||
->method('getName')
|
||||
->will($this->returnValue($indexName));
|
||||
|
||||
$typeMock->expects($this->any())
|
||||
->method('getIndex')
|
||||
->will($this->returnValue($indexMock));
|
||||
|
||||
$typeMock->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue($typeName));
|
||||
|
||||
return $typeMock;
|
||||
}
|
||||
}
|
224
Tests/Persister/ObjectPersisterTest.php
Normal file
224
Tests/Persister/ObjectPersisterTest.php
Normal file
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Tests\ObjectPersister;
|
||||
|
||||
use FOQ\ElasticaBundle\Persister\ObjectPersister;
|
||||
use FOQ\ElasticaBundle\Transformer\ModelToElasticaAutoTransformer;
|
||||
|
||||
class POPO
|
||||
{
|
||||
public $id = 123;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'popoName';
|
||||
}
|
||||
}
|
||||
|
||||
class InvalidObjectPersister extends ObjectPersister
|
||||
{
|
||||
protected function transformToElasticaDocument($object)
|
||||
{
|
||||
throw new \Exception('Invalid transformation');
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectPersisterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (!class_exists('Elastica_Type')) {
|
||||
$this->markTestSkipped('The Elastica library classes are not available');
|
||||
}
|
||||
}
|
||||
|
||||
public function testThatCanReplaceObject()
|
||||
{
|
||||
$modelTransformer = new ModelToElasticaAutoTransformer();
|
||||
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typeMock->expects($this->once())
|
||||
->method('deleteById')
|
||||
->with($this->equalTo(123));
|
||||
$typeMock->expects($this->once())
|
||||
->method('addDocument');
|
||||
|
||||
$mappingMock = $this->getMockBuilder('FOQ\ElasticaBundle\MappingRegistry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mappingMock->expects($this->once())
|
||||
->method('getTypeFieldNames')
|
||||
->will($this->returnValue(array('name')));
|
||||
|
||||
$objectPersister = new ObjectPersister($typeMock, $modelTransformer, 'SomeClass', $mappingMock);
|
||||
$objectPersister->replaceOne(new POPO());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testThatErrorIsHandledWhenCannotReplaceObject()
|
||||
{
|
||||
$modelTransformer = new ModelToElasticaAutoTransformer();
|
||||
|
||||
$mappingMock = $this->getMockBuilder('FOQ\ElasticaBundle\MappingRegistry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typeMock->expects($this->never())
|
||||
->method('deleteById');
|
||||
$typeMock->expects($this->never())
|
||||
->method('addDocument');
|
||||
|
||||
$objectPersister = new InvalidObjectPersister($typeMock, $modelTransformer, 'SomeClass', $mappingMock);
|
||||
$objectPersister->replaceOne(new POPO());
|
||||
}
|
||||
|
||||
public function testThatCanInsertObject()
|
||||
{
|
||||
$modelTransformer = new ModelToElasticaAutoTransformer();
|
||||
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typeMock->expects($this->never())
|
||||
->method('deleteById');
|
||||
$typeMock->expects($this->once())
|
||||
->method('addDocument');
|
||||
|
||||
$mappingMock = $this->getMockBuilder('FOQ\ElasticaBundle\MappingRegistry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mappingMock->expects($this->once())
|
||||
->method('getTypeFieldNames')
|
||||
->will($this->returnValue(array('name')));
|
||||
|
||||
$objectPersister = new ObjectPersister($typeMock, $modelTransformer, 'SomeClass', $mappingMock);
|
||||
$objectPersister->insertOne(new POPO());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testThatErrorIsHandledWhenCannotInsertObject()
|
||||
{
|
||||
$modelTransformer = new ModelToElasticaAutoTransformer();
|
||||
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typeMock->expects($this->never())
|
||||
->method('deleteById');
|
||||
$typeMock->expects($this->never())
|
||||
->method('addDocument');
|
||||
|
||||
$objectPersister = new InvalidObjectPersister($typeMock, $modelTransformer, 'SomeClass', $mappingMock);
|
||||
$objectPersister->insertOne(new POPO());
|
||||
}
|
||||
|
||||
public function testThatCanDeleteObject()
|
||||
{
|
||||
$modelTransformer = new ModelToElasticaAutoTransformer();
|
||||
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typeMock->expects($this->once())
|
||||
->method('deleteById');
|
||||
$typeMock->expects($this->never())
|
||||
->method('addDocument');
|
||||
|
||||
$mappingMock = $this->getMockBuilder('FOQ\ElasticaBundle\MappingRegistry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mappingMock->expects($this->any())
|
||||
->method('getTypeFieldNames')
|
||||
->will($this->returnValue(array('name')));
|
||||
|
||||
$objectPersister = new ObjectPersister($typeMock, $modelTransformer, 'SomeClass', $mappingMock);
|
||||
$objectPersister->deleteOne(new POPO());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testThatErrorIsHandledWhenCannotDeleteObject()
|
||||
{
|
||||
$modelTransformer = new ModelToElasticaAutoTransformer();
|
||||
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typeMock->expects($this->never())
|
||||
->method('deleteById');
|
||||
$typeMock->expects($this->never())
|
||||
->method('addDocument');
|
||||
|
||||
$mappingMock = $this->getMockBuilder('FOQ\ElasticaBundle\MappingRegistry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$objectPersister = new InvalidObjectPersister($typeMock, $modelTransformer, 'SomeClass', $mappingMock);
|
||||
$objectPersister->deleteOne(new POPO());
|
||||
}
|
||||
|
||||
public function testThatCanInsertManyObjects()
|
||||
{
|
||||
$modelTransformer = new ModelToElasticaAutoTransformer();
|
||||
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typeMock->expects($this->never())
|
||||
->method('deleteById');
|
||||
$typeMock->expects($this->never())
|
||||
->method('addDocument');
|
||||
$typeMock->expects($this->once())
|
||||
->method('addDocuments');
|
||||
|
||||
$mappingMock = $this->getMockBuilder('FOQ\ElasticaBundle\MappingRegistry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mappingMock->expects($this->any())
|
||||
->method('getTypeFieldNames')
|
||||
->will($this->returnValue(array('name')));
|
||||
|
||||
$objectPersister = new ObjectPersister($typeMock, $modelTransformer, 'SomeClass', $mappingMock);
|
||||
$objectPersister->insertMany(array(new POPO(), new POPO()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function testThatErrorIsHandledWhenCannotInsertManyObject()
|
||||
{
|
||||
$modelTransformer = new ModelToElasticaAutoTransformer();
|
||||
|
||||
$typeMock = $this->getMockBuilder('Elastica_Type')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typeMock->expects($this->never())
|
||||
->method('deleteById');
|
||||
$typeMock->expects($this->never())
|
||||
->method('addDocument');
|
||||
$typeMock->expects($this->never())
|
||||
->method('addDocuments');
|
||||
|
||||
$mappingMock = $this->getMockBuilder('FOQ\ElasticaBundle\MappingRegistry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$objectPersister = new InvalidObjectPersister($typeMock, $modelTransformer, 'SomeClass', $mappingMock);
|
||||
$objectPersister->insertMany(array(new POPO(), new POPO()));
|
||||
}
|
||||
}
|
60
Tests/PopulatorTest.php
Executable file
60
Tests/PopulatorTest.php
Executable file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Tests\Populator;
|
||||
|
||||
use FOQ\ElasticaBundle\Populator;
|
||||
use FOQ\ElasticaBundle\Provider\ProviderInterface;
|
||||
use Closure;
|
||||
|
||||
class PopulatorMock extends Populator
|
||||
{
|
||||
public $providers = array();
|
||||
}
|
||||
|
||||
class PopulatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testThatWeCanAddProvider()
|
||||
{
|
||||
$provider = $this->getMock('FOQ\ElasticaBundle\Provider\ProviderInterface', array('populate'));
|
||||
|
||||
$populator = new PopulatorMock(array());
|
||||
$populator->addProvider('l3l0Provider', $provider);
|
||||
|
||||
$this->assertEquals(count($populator->providers), 1);
|
||||
$this->assertArrayHasKey('l3l0Provider', $populator->providers);
|
||||
$this->assertInstanceOf('FOQ\ElasticaBundle\Provider\ProviderInterface', $populator->providers['l3l0Provider']);
|
||||
}
|
||||
|
||||
public function testThatPopulateThroughProviders()
|
||||
{
|
||||
$provider = $this->getMock('FOQ\ElasticaBundle\Provider\ProviderInterface', array('populate'));
|
||||
$provider->expects($this->once())
|
||||
->method('populate');
|
||||
|
||||
$provider2 = $this->getMock('FOQ\ElasticaBundle\Provider\ProviderInterface', array('populate'));
|
||||
$provider2->expects($this->once())
|
||||
->method('populate');
|
||||
|
||||
$populator = new Populator(array('l3l0Provider' => $provider, 'secondProvider' => $provider2));
|
||||
$populator->populate(function ($text) { return $text; });
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testThatAddProviderHaveToImpelementProviderInterface()
|
||||
{
|
||||
$populator = new Populator(array());
|
||||
$populator->addProvider('provider', new \stdClass());
|
||||
$populator->populate(function ($text) { return $text; });
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testThatProvidersPassToTheContructorHaveToImplementProviderInterface()
|
||||
{
|
||||
$populator = new Populator(array('provider' => new \stdClass()));
|
||||
$populator->populate(function ($text) { return $text; });
|
||||
}
|
||||
}
|
108
Tests/ReseterTest.php
Normal file
108
Tests/ReseterTest.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Tests\Reseter;
|
||||
|
||||
use FOQ\ElasticaBundle\Reseter;
|
||||
use FOQ\ElasticaBundle\IndexManager;
|
||||
use Elastica_Exception_Response;
|
||||
use Elastica_Response;
|
||||
|
||||
class Index
|
||||
{
|
||||
public $deleted = false;
|
||||
public $created = false;
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->deleted = true;
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->created = true;
|
||||
}
|
||||
}
|
||||
|
||||
class NewIndex
|
||||
{
|
||||
public $deleted = false;
|
||||
public $created = false;
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$jsonResponse = json_encode(array('index' => 'is_new'));
|
||||
|
||||
throw new Elastica_Exception_Response(new Elastica_Response($jsonResponse));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->created = true;
|
||||
}
|
||||
}
|
||||
|
||||
class ReseterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (!class_exists('Elastica_Exception_Response') || !class_exists('Elastica_Response')) {
|
||||
$this->markTestSkipped('The Elastica library classes are not available');
|
||||
}
|
||||
}
|
||||
|
||||
public function testThatResetMethodDeleteAllIndexes()
|
||||
{
|
||||
$indexManager = new IndexManager(array(
|
||||
'index_1' => new Index(),
|
||||
'index_2' => new Index()
|
||||
), new Index());
|
||||
|
||||
$reseter = new Reseter($indexManager);
|
||||
$reseter->reset();
|
||||
|
||||
$this->assertTrue($indexManager->getIndex('index_1')->deleted);
|
||||
$this->assertTrue($indexManager->getIndex('index_2')->deleted);
|
||||
}
|
||||
|
||||
public function testThatResetMethodDoesNotDeleteNewIndexes()
|
||||
{
|
||||
$indexManager = new IndexManager(array(
|
||||
'index_1' => new Index(),
|
||||
'index_2' => new NewIndex()
|
||||
), new Index());
|
||||
|
||||
$reseter = new Reseter($indexManager);
|
||||
$reseter->reset();
|
||||
|
||||
$this->assertTrue($indexManager->getIndex('index_1')->deleted);
|
||||
$this->assertFalse($indexManager->getIndex('index_2')->deleted);
|
||||
}
|
||||
|
||||
public function testThatResetMethodRecreateAllIndexes()
|
||||
{
|
||||
$indexManager = new IndexManager(array(
|
||||
'index_1' => new Index(),
|
||||
'index_2' => new Index()
|
||||
), new Index());
|
||||
|
||||
$reseter = new Reseter($indexManager);
|
||||
$reseter->reset();
|
||||
|
||||
$this->assertTrue($indexManager->getIndex('index_1')->created);
|
||||
$this->assertTrue($indexManager->getIndex('index_2')->created);
|
||||
}
|
||||
|
||||
public function testThatResetMethodCreateNewIndexes()
|
||||
{
|
||||
$indexManager = new IndexManager(array(
|
||||
'index_1' => new NewIndex(),
|
||||
'index_2' => new NewIndex()
|
||||
), new NewIndex());
|
||||
|
||||
$reseter = new Reseter($indexManager);
|
||||
$reseter->reset();
|
||||
|
||||
$this->assertTrue($indexManager->getIndex('index_1')->created);
|
||||
$this->assertTrue($indexManager->getIndex('index_2')->created);
|
||||
}
|
||||
}
|
83
Tests/Transformer/ModelToElasticaAutoTransformerTest.php
Normal file
83
Tests/Transformer/ModelToElasticaAutoTransformerTest.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Tests\Transformer\ModelToElasticaAutoTransformer;
|
||||
|
||||
use FOQ\ElasticaBundle\Transformer\ModelToElasticaAutoTransformer;
|
||||
|
||||
class POPO
|
||||
{
|
||||
public $id = 123;
|
||||
public $name = 'someName';
|
||||
public $desc = 'desc';
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
$iterator = new \ArrayIterator();
|
||||
$iterator->append('value1');
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
public function getArray()
|
||||
{
|
||||
return array('key1' => 'value1', 'key2' => 'value2');
|
||||
}
|
||||
}
|
||||
|
||||
class ModelToElasticaAutoTransformerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (!class_exists('Elastica_Document')) {;
|
||||
$this->markTestSkipped('The Elastica library classes are not available');
|
||||
}
|
||||
}
|
||||
|
||||
public function testThatCanTransformObject()
|
||||
{
|
||||
$transformer = new ModelToElasticaAutoTransformer();
|
||||
$document = $transformer->transform(new POPO(), array('name'));
|
||||
$data = $document->getData();
|
||||
|
||||
$this->assertInstanceOf('Elastica_Document', $document);
|
||||
$this->assertEquals(123, $document->getId());
|
||||
$this->assertEquals('someName', $data['name']);
|
||||
}
|
||||
|
||||
public function testThatCanTransformObjectWithIteratorValue()
|
||||
{
|
||||
$transformer = new ModelToElasticaAutoTransformer();
|
||||
$document = $transformer->transform(new POPO(), array('iterator'));
|
||||
$data = $document->getData();
|
||||
|
||||
$this->assertEquals(array('value1'), $data['iterator']);
|
||||
}
|
||||
|
||||
public function testThatCanTransformObjectWithArrayValue()
|
||||
{
|
||||
$transformer = new ModelToElasticaAutoTransformer();
|
||||
$document = $transformer->transform(new POPO(), array('array'));
|
||||
$data = $document->getData();
|
||||
|
||||
$this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $data['array']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testThatCannotTransformObjectWhenGetterDoesNotExists()
|
||||
{
|
||||
$transformer = new ModelToElasticaAutoTransformer();
|
||||
$document = $transformer->transform(new POPO(), array('desc'));
|
||||
}
|
||||
}
|
29
phpunit.dist.xml
Normal file
29
phpunit.dist.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="false"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="../../../app/bootstrap.php.cache"
|
||||
>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="ElasticaBundle Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Tests</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
Loading…
Reference in a new issue