Fix test, add test for failing mappings

This commit is contained in:
Tim Nagel 2014-06-16 23:28:53 +10:00
parent 14083496d7
commit 0383811834
2 changed files with 32 additions and 5 deletions

View file

@ -2,6 +2,9 @@
namespace FOS\ElasticaBundle\Tests\Doctrine;
use Elastica\Bulk\ResponseSet;
use Elastica\Response;
class AbstractProviderTest extends \PHPUnit_Framework_TestCase
{
private $objectClass;
@ -177,9 +180,9 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
*/
private function getMockBulkResponseException()
{
return $this->getMockBuilder('Elastica\Exception\Bulk\ResponseException')
->disableOriginalConstructor()
->getMock();
return $this->getMock('Elastica\Exception\Bulk\ResponseException', null, array(
new ResponseSet(new Response(array()), array())
));
}
/**

View file

@ -18,13 +18,28 @@ use Symfony\Bundle\FrameworkBundle\Client;
*/
class MappingToElasticaTest extends WebTestCase
{
public function testReset()
public function testResetIndexAddsMappings()
{
$client = $this->createClient(array('test_case' => 'Basic'));
$resetter = $this->getResetter($client);
$resetter->resetIndex('index');
$type = $this->getType($client);
$mapping = $type->getMapping();
$this->assertNotEmpty($mapping, 'Mapping was populated');
}
public function testResetType()
{
$client = $this->createClient(array('test_case' => 'Basic'));
$resetter = $this->getResetter($client);
$resetter->resetIndexType('index', 'type');
$type = $this->getType($client);
$mapping = $type->getMapping();
$this->assertNotEmpty($mapping, 'Mapping was populated');
}
/**
@ -36,6 +51,15 @@ class MappingToElasticaTest extends WebTestCase
return $client->getContainer()->get('fos_elastica.resetter');
}
/**
* @param Client $client
* @return \Elastica\Type
*/
private function getType(Client $client)
{
return $client->getContainer()->get('fos_elastica.index.index.type');
}
protected function setUp()
{
parent::setUp();