summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:47 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:47 -0400
commit7e85254903c7c0cb49e381f16b18441ea7b058cc (patch)
treeb22328fcf4c8408fc25a7acb73d1cb1089cd82ac /vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
parent1de335ad3f395ca6861085393ba366a9e3fb4a0d (diff)
parent1a365e77dfb8825136626202b1df462731b42060 (diff)
Merge commit '1a365e'
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php')
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php97
1 files changed, 97 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
new file mode 100644
index 00000000..fab77600
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
@@ -0,0 +1,97 @@
+<?php
+
+namespace Elastica\Test;
+
+use Elastica\Param;
+use Elastica\Util;
+use Elastica\Test\Base as BaseTest;
+
+class ParamTest extends BaseTest
+{
+ public function testToArrayEmpty()
+ {
+ $param = new Param();
+ $this->assertInstanceOf('Elastica\Param', $param);
+ $this->assertEquals(array($this->_getFilterName($param) => array()), $param->toArray());
+ }
+
+ public function testSetParams()
+ {
+ $param = new Param();
+ $params = array('hello' => 'word', 'nicolas' => 'ruflin');
+ $param->setParams($params);
+
+ $this->assertInstanceOf('Elastica\Param', $param);
+ $this->assertEquals(array($this->_getFilterName($param) => $params), $param->toArray());
+ }
+
+ public function testSetGetParam()
+ {
+ $param = new Param();
+
+ $key = 'name';
+ $value = 'nicolas ruflin';
+
+ $params = array($key => $value);
+ $param->setParam($key, $value);
+
+ $this->assertEquals($params, $param->getParams());
+ $this->assertEquals($value, $param->getParam($key));
+ }
+
+ public function testAddParam()
+ {
+ $param = new Param();
+
+ $key = 'name';
+ $value = 'nicolas ruflin';
+
+ $param->addParam($key, $value);
+
+ $this->assertEquals(array($key => array($value)), $param->getParams());
+ $this->assertEquals(array($value), $param->getParam($key));
+ }
+
+ public function testAddParam2()
+ {
+ $param = new Param();
+
+ $key = 'name';
+ $value1 = 'nicolas';
+ $value2 = 'ruflin';
+
+ $param->addParam($key, $value1);
+ $param->addParam($key, $value2);
+
+ $this->assertEquals(array($key => array($value1, $value2)), $param->getParams());
+ $this->assertEquals(array($value1, $value2), $param->getParam($key));
+ }
+
+ /**
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testGetParamInvalid()
+ {
+ $param = new Param();
+
+ $param->getParam('notest');
+ }
+
+ public function testHasParam()
+ {
+ $param = new Param();
+
+ $key = 'name';
+ $value = 'nicolas ruflin';
+
+ $this->assertFalse($param->hasParam($key));
+
+ $param->setParam($key, $value);
+ $this->assertTrue($param->hasParam($key));
+ }
+
+ protected function _getFilterName($filter)
+ {
+ return Util::getParamName($filter);
+ }
+}