diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:15:42 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:44:51 +0100 |
commit | a1789ddde42033f1b05cc4929491214ee6e79383 (patch) | |
tree | 63615735c4ddffaaabf2428946bb26f90899f7bf /vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php | 65 |
1 files changed, 65 insertions, 0 deletions
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..6fc975e7 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php @@ -0,0 +1,65 @@ +<?php +namespace Elastica\Test\Exception; + +use Elastica\Document; +use Elastica\Exception\ResponseException; + +class ResponseExceptionTest extends AbstractExceptionTest +{ + /** + * @group functional + */ + public function testCreateExistingIndex() + { + $this->_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()); + } + } + + /** + * @group functional + */ + public function testBadType() + { + $index = $this->_createIndex(); + $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()); + } + } + + /** + * @group functional + */ + public function testWhatever() + { + $index = $this->_createIndex(); + $index->delete(); + + try { + $index->search(); + } catch (ResponseException $ex) { + $this->assertEquals('IndexMissingException', $ex->getElasticsearchException()->getExceptionName()); + $this->assertEquals(404, $ex->getElasticsearchException()->getCode()); + } + } +} |