From 1a365e77dfb8825136626202b1df462731b42060 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 16 Aug 2015 08:22:05 +0200 Subject: Update to MediaWiki 1.25.2 --- .../Elastica/Test/Exception/NotImplementedTest.php | 23 +++++++++ .../Exception/PartialShardFailureExceptionTest.php | 55 ++++++++++++++++++++ .../Test/Exception/ResponseExceptionTest.php | 60 ++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Exception') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php new file mode 100644 index 00000000..ff704638 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php @@ -0,0 +1,23 @@ +assertInstanceOf('Elastica\Exception\NotImplementedException', $exception); + $this->assertInstanceOf('Elastica\Exception\ExceptionInterface', $exception); + $this->assertInstanceOf('Exception', $exception); + + $this->assertEquals($message, $exception->getMessage()); + $this->assertEquals($code, $exception->getCode()); + } +} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php new file mode 100644 index 00000000..31698e26 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php @@ -0,0 +1,55 @@ +_getClient(); + $index = $client->getIndex('elastica_partial_failure'); + $index->create(array( + 'index' => array( + 'number_of_shards' => 5, + 'number_of_replicas' => 0 + ) + ), true); + + $type = $index->getType('folks'); + + $type->addDocument(new Document('', array('name' => 'ruflin'))); + $type->addDocument(new Document('', array('name' => 'bobrik'))); + $type->addDocument(new Document('', array('name' => 'kimchy'))); + + $index->refresh(); + + $query = Query::create(array( + 'query' => array( + 'filtered' => array( + 'filter' => array( + 'script' => array( + 'script' => 'doc["undefined"] > 8', // compiles, but doesn't work + ), + ), + ), + ), + )); + + try { + $index->search($query); + + $this->fail('PartialShardFailureException should have been thrown'); + } catch (PartialShardFailureException $e) { + $resultSet = new ResultSet($e->getResponse(), $query); + $this->assertEquals(0, count($resultSet->getResults())); + } + } + +} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php new file mode 100644 index 00000000..06b5462b --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php @@ -0,0 +1,60 @@ +_createIndex('woo', true); + + try { + $this->_createIndex('woo', false); + $this->fail('Index created when it should fail'); + } catch (ResponseException $ex) { + $this->assertEquals('IndexAlreadyExistsException', $ex->getElasticsearchException()->getExceptionName()); + $this->assertEquals(400, $ex->getElasticsearchException()->getCode()); + } + } + + public function testBadType() + { + $index = $this->_createIndex('woo'); + $type = $index->getType('test'); + + $type->setMapping(array( + 'num' => array( + 'type' => 'long' + ) + )); + + try { + $type->addDocument(new Document('', array( + 'num' => 'not number at all', + ))); + $this->fail('Indexing with wrong type should fail'); + } catch (ResponseException $ex) { + $this->assertEquals('MapperParsingException', $ex->getElasticsearchException()->getExceptionName()); + $this->assertEquals(400, $ex->getElasticsearchException()->getCode()); + } + } + + public function testWhatever() + { + $index = $this->_createIndex('woo'); + $index->delete(); + + try { + $index->search(); + } catch (ResponseException $ex) { + $this->assertEquals('IndexMissingException', $ex->getElasticsearchException()->getExceptionName()); + $this->assertEquals(404, $ex->getElasticsearchException()->getCode()); + } + } + +} -- cgit v1.2.3-54-g00ecf