blob: 6fc975e76af018810dfaf621654461dbc27c2373 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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());
}
}
}
|