From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- .../elastica/test/lib/Elastica/Test/ScriptTest.php | 169 +++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php new file mode 100644 index 00000000..b42d8646 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php @@ -0,0 +1,169 @@ + $value, + ); + $this->assertEquals($value, $script->getScript()); + $this->assertEquals($expected, $script->toArray()); + + $params = array( + 'param1' => 'one', + 'param2' => 10, + ); + + $script = new Script($value, $params); + + $expected = array( + 'script' => $value, + 'params' => $params, + ); + + $this->assertEquals($value, $script->getScript()); + $this->assertEquals($params, $script->getParams()); + $this->assertEquals($expected, $script->toArray()); + + $lang = 'mvel'; + + $script = new Script($value, $params, $lang); + + $expected = array( + 'script' => $value, + 'params' => $params, + 'lang' => $lang, + ); + + $this->assertEquals($value, $script->getScript()); + $this->assertEquals($params, $script->getParams()); + $this->assertEquals($lang, $script->getLang()); + $this->assertEquals($expected, $script->toArray()); + } + + /** + * @group unit + */ + public function testCreateString() + { + $string = '_score * 2.0'; + $script = Script::create($string); + + $this->assertInstanceOf('Elastica\Script', $script); + + $this->assertEquals($string, $script->getScript()); + + $expected = array( + 'script' => $string, + ); + $this->assertEquals($expected, $script->toArray()); + } + + /** + * @group unit + */ + public function testCreateScript() + { + $data = new Script('_score * 2.0'); + + $script = Script::create($data); + + $this->assertInstanceOf('Elastica\Script', $script); + $this->assertSame($data, $script); + } + + /** + * @group unit + */ + public function testCreateArray() + { + $string = '_score * 2.0'; + $lang = 'mvel'; + $params = array( + 'param1' => 'one', + 'param2' => 1, + ); + $array = array( + 'script' => $string, + 'lang' => $lang, + 'params' => $params, + ); + + $script = Script::create($array); + + $this->assertInstanceOf('Elastica\Script', $script); + + $this->assertEquals($string, $script->getScript()); + $this->assertEquals($params, $script->getParams()); + $this->assertEquals($lang, $script->getLang()); + + $this->assertEquals($array, $script->toArray()); + } + + /** + * @group unit + * @dataProvider dataProviderCreateInvalid + * @expectedException \Elastica\Exception\InvalidException + */ + public function testCreateInvalid($data) + { + Script::create($data); + } + + /** + * @return array + */ + public function dataProviderCreateInvalid() + { + return array( + array( + new \stdClass(), + ), + array( + array('params' => array('param1' => 'one')), + ), + array( + array('script' => '_score * 2.0', 'params' => 'param'), + ), + ); + } + + /** + * @group unit + */ + public function testSetLang() + { + $script = new Script('foo', array(), Script::LANG_GROOVY); + $this->assertEquals(Script::LANG_GROOVY, $script->getLang()); + + $script->setLang(Script::LANG_PYTHON); + $this->assertEquals(Script::LANG_PYTHON, $script->getLang()); + + $this->assertInstanceOf('Elastica\Script', $script->setLang(Script::LANG_PYTHON)); + } + + /** + * @group unit + */ + public function testSetScript() + { + $script = new Script('foo'); + $this->assertEquals('foo', $script->getScript()); + + $script->setScript('bar'); + $this->assertEquals('bar', $script->getScript()); + + $this->assertInstanceOf('Elastica\Script', $script->setScript('foo')); + } +} -- cgit v1.2.3-54-g00ecf