{{ query.data|json_encode }}
@@ -60,7 +61,7 @@
- curl -X{{ query.method }} '{{ query.connection.transport|lower }}://{{ query.connection.host }}:{{ query.connection.port }}/{{ query.path }}' -d '{{ query.data|json_encode }}'
+ curl -X{{ query.method }} '{{ query.connection.transport|lower }}://{{ query.connection.host }}:{{ query.connection.port }}/{{ query.path }}{% if query.queryString|length %}?{{ query.queryString|url_encode }}{% endif %}' -d '{{ query.data|json_encode }}'
{% endif %}
diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php
index c8509cf..8a9d91a 100644
--- a/Tests/ClientTest.php
+++ b/Tests/ClientTest.php
@@ -24,6 +24,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
Request::GET,
$this->isType('array'),
$this->isType('float'),
+ $this->isType('array'),
$this->isType('array')
);
diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php
index 35b2af3..0f0d374 100644
--- a/Tests/DependencyInjection/ConfigurationTest.php
+++ b/Tests/DependencyInjection/ConfigurationTest.php
@@ -3,6 +3,7 @@
namespace FOS\ElasticaBundle\Tests\Resetter\DependencyInjection;
use FOS\ElasticaBundle\DependencyInjection\Configuration;
+use Symfony\Component\Config\Definition\Processor;
/**
* ConfigurationTest
@@ -85,4 +86,21 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\Component\Config\Definition\ScalarNode', $mapping['index']);
$this->assertNull($mapping['index']->getDefaultValue());
}
+
+ public function testSlashIsAddedAtTheEndOfServerUrl()
+ {
+ $config = array(
+ 'clients' => array(
+ 'default' => array(
+ 'url' => 'http://www.github.com',
+ ),
+ ),
+ );
+
+ $processor = new Processor();
+
+ $configuration = $processor->processConfiguration($this->configuration, array($config));
+
+ $this->assertEquals('http://www.github.com/', $configuration['clients']['default']['servers'][0]['url']);
+ }
}
diff --git a/Tests/Doctrine/AbstractProviderTest.php b/Tests/Doctrine/AbstractProviderTest.php
index 0a9aceb..2492eed 100644
--- a/Tests/Doctrine/AbstractProviderTest.php
+++ b/Tests/Doctrine/AbstractProviderTest.php
@@ -135,6 +135,30 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($loggerClosureInvoked);
}
+ public function testPopulateNotStopOnError()
+ {
+ $nbObjects = 1;
+ $objects = array(1);
+
+ $provider = $this->getMockAbstractProvider();
+
+ $provider->expects($this->any())
+ ->method('countObjects')
+ ->will($this->returnValue($nbObjects));
+
+ $provider->expects($this->any())
+ ->method('fetchSlice')
+ ->will($this->returnValue($objects));
+
+ $this->objectPersister->expects($this->any())
+ ->method('insertMany')
+ ->will($this->throwException($this->getMockBulkResponseException()));
+
+ $this->setExpectedException('Elastica\Exception\Bulk\ResponseException');
+
+ $provider->populate(null, array('ignore-errors' => false));
+ }
+
/**
* @return \FOS\ElasticaBundle\Doctrine\AbstractProvider|\PHPUnit_Framework_MockObject_MockObject
*/
@@ -148,6 +172,16 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
));
}
+ /**
+ * @return \Elastica\Exception\Bulk\ResponseException
+ */
+ private function getMockBulkResponseException()
+ {
+ return $this->getMockBuilder('Elastica\Exception\Bulk\ResponseException')
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
/**
* @return \Doctrine\Common\Persistence\ManagerRegistry|\PHPUnit_Framework_MockObject_MockObject
*/
diff --git a/Tests/Logger/ElasticaLoggerTest.php b/Tests/Logger/ElasticaLoggerTest.php
index 30ce30c..96adf53 100644
--- a/Tests/Logger/ElasticaLoggerTest.php
+++ b/Tests/Logger/ElasticaLoggerTest.php
@@ -70,6 +70,7 @@ class ElasticaLoggerTest extends \PHPUnit_Framework_TestCase
$data = array('data');
$time = 12;
$connection = array('host' => 'localhost', 'port' => '8999', 'transport' => 'https');
+ $query = array('search_type' => 'dfs_query_then_fetch');
$expected = array(
'path' => $path,
@@ -77,9 +78,10 @@ class ElasticaLoggerTest extends \PHPUnit_Framework_TestCase
'data' => $data,
'executionMS' => $time,
'connection' => $connection,
+ 'queryString' => $query,
);
- $elasticaLogger->logQuery($path, $method, $data, $time, $connection);
+ $elasticaLogger->logQuery($path, $method, $data, $time, $connection, $query);
$returnedQueries = $elasticaLogger->getQueries();
$this->assertEquals($expected, $returnedQueries[0]);
}
diff --git a/Tests/ResetterTest.php b/Tests/ResetterTest.php
index aa0fbcc..b4e5649 100644
--- a/Tests/ResetterTest.php
+++ b/Tests/ResetterTest.php
@@ -2,6 +2,9 @@
namespace FOS\ElasticaBundle\Tests\Resetter;
+use Elastica\Exception\ResponseException;
+use Elastica\Request;
+use Elastica\Response;
use FOS\ElasticaBundle\Resetter;
use Elastica\Type\Mapping;
@@ -130,6 +133,32 @@ class ResetterTest extends \PHPUnit_Framework_TestCase
$resetter->resetIndexType('foo', 'c');
}
+ public function testResetIndexTypeIgnoreTypeMissingException()
+ {
+ $type = $this->getMockElasticaType();
+
+ $this->indexConfigsByName['foo']['index']->expects($this->once())
+ ->method('getType')
+ ->with('a')
+ ->will($this->returnValue($type));
+
+ $type->expects($this->once())
+ ->method('delete')
+ ->will($this->throwException(new ResponseException(
+ new Request(''),
+ new Response(array('error' => 'TypeMissingException[[de_20131022] type[bla] missing]', 'status' => 404)))
+ ));
+
+ $mapping = Mapping::create($this->indexConfigsByName['foo']['config']['mappings']['a']['properties']);
+ $mapping->setParam('dynamic_templates', $this->indexConfigsByName['foo']['config']['mappings']['a']['dynamic_templates']);
+ $type->expects($this->once())
+ ->method('setMapping')
+ ->with($mapping);
+
+ $resetter = new Resetter($this->indexConfigsByName);
+ $resetter->resetIndexType('foo', 'a');
+ }
+
public function testIndexMappingForParent()
{
$type = $this->getMockElasticaType();
diff --git a/Transformer/ElasticaToModelTransformerCollection.php b/Transformer/ElasticaToModelTransformerCollection.php
index a261e81..f65f8db 100644
--- a/Transformer/ElasticaToModelTransformerCollection.php
+++ b/Transformer/ElasticaToModelTransformerCollection.php
@@ -67,7 +67,9 @@ class ElasticaToModelTransformerCollection implements ElasticaToModelTransformer
$result = array();
foreach ($elasticaObjects as $object) {
- $result[] = $transformed[$object->getType()][$object->getId()];
+ if (array_key_exists($object->getId(), $transformed[$object->getType()])) {
+ $result[] = $transformed[$object->getType()][$object->getId()];
+ }
}
return $result;
diff --git a/composer.json b/composer.json
index 094eba5..e588494 100644
--- a/composer.json
+++ b/composer.json
@@ -16,7 +16,7 @@
"symfony/console": "~2.1",
"symfony/form": "~2.1",
"symfony/property-access": "~2.2",
- "ruflin/elastica": "~0.20",
+ "ruflin/elastica": ">=0.20, <1.1-dev",
"psr/log": "~1.0"
},
"require-dev":{