diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-18 06:00:00 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-18 06:00:00 +0100 |
commit | 15e69f7b20b6596b9148030acce5b59993b95a45 (patch) | |
tree | 7b828b8920b0e222dc2a2c97dde933c9c4864fab /vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.25.4
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php new file mode 100644 index 00000000..178883a8 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php @@ -0,0 +1,69 @@ +<?php + +namespace Elastica\Test\Bulk; + +use Elastica\Bulk\Action; +use Elastica\Bulk; +use Elastica\Client; +use Elastica\Exception\Bulk\ResponseException; +use Elastica\Index; +use Elastica\Test\Base as BaseTest; +use Elastica\Bulk\ResponseSet; +use Elastica\Response; +use Elastica\Type; + +class ActionTest extends BaseTest +{ + public function testAction() + { + $action = new Action(); + $this->assertEquals('index', $action->getOpType()); + $this->assertFalse($action->hasSource()); + + $expected = '{"index":{}}' . "\n"; + $this->assertEquals($expected, $action->toString()); + + $action->setIndex('index'); + + $expected = '{"index":{"_index":"index"}}' . "\n"; + $this->assertEquals($expected, $action->toString()); + + $action->setType('type'); + + $expected = '{"index":{"_index":"index","_type":"type"}}' . "\n"; + $this->assertEquals($expected, $action->toString()); + + $action->setId(1); + $expected = '{"index":{"_index":"index","_type":"type","_id":1}}' . "\n"; + $this->assertEquals($expected, $action->toString()); + + $action->setRouting(1); + $expected = '{"index":{"_index":"index","_type":"type","_id":1,"_routing":1}}' . "\n"; + $this->assertEquals($expected, $action->toString()); + + $client = new Client(); + $index = new Index($client, 'index2'); + $type = new Type($index, 'type2'); + + $action->setIndex($index); + + $expected = '{"index":{"_index":"index2","_type":"type","_id":1,"_routing":1}}' . "\n"; + $this->assertEquals($expected, $action->toString()); + + $action->setType($type); + + $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}' . "\n"; + $this->assertEquals($expected, $action->toString()); + + $action->setSource(array('user' => 'name')); + + $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}' . "\n"; + $expected.= '{"user":"name"}' . "\n"; + + $this->assertEquals($expected, $action->toString()); + $this->assertTrue($action->hasSource()); + + $this->assertFalse(Action::isValidOpType('foo')); + $this->assertTrue(Action::isValidOpType('delete')); + } +} |