summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php')
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
new file mode 100644
index 00000000..20573cc7
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
@@ -0,0 +1,80 @@
+<?php
+namespace Elastica\Test\Transport;
+
+use Elastica\Connection;
+use Elastica\Transport\AbstractTransport;
+use Elastica\Transport\Http;
+
+class AbstractTransportTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * Return transport configuration and the expected HTTP method.
+ *
+ * @return array[]
+ */
+ public function getValidDefinitions()
+ {
+ $connection = new Connection();
+
+ return array(
+ array('Http'),
+ array(array('type' => 'Http')),
+ array(array('type' => new Http())),
+ array(new Http()),
+ );
+ }
+
+ /**
+ * @group unit
+ * @dataProvider getValidDefinitions
+ */
+ public function testCanCreateTransportInstances($transport)
+ {
+ $connection = new Connection();
+ $params = array();
+ $transport = AbstractTransport::create($transport, $connection, $params);
+ $this->assertInstanceOf('Elastica\Transport\AbstractTransport', $transport);
+ $this->assertSame($connection, $transport->getConnection());
+ }
+
+ public function getInvalidDefinitions()
+ {
+ return array(
+ array(array('transport' => 'Http')),
+ array('InvalidTransport'),
+ );
+ }
+
+ /**
+ * @group unit
+ * @dataProvider getInvalidDefinitions
+ * @expectedException Elastica\Exception\InvalidException
+ * @expectedExceptionMessage Invalid transport
+ */
+ public function testThrowsExecptionOnInvalidTransportDefinition($transport)
+ {
+ AbstractTransport::create($transport, new Connection());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testCanInjectParamsWhenUsingArray()
+ {
+ $connection = new Connection();
+ $params = array(
+ 'param1' => 'some value',
+ 'param3' => 'value3',
+ );
+
+ $transport = AbstractTransport::create(array(
+ 'type' => 'Http',
+ 'param1' => 'value1',
+ 'param2' => 'value2',
+ ), $connection, $params);
+
+ $this->assertSame('value1', $transport->getParam('param1'));
+ $this->assertSame('value2', $transport->getParam('param2'));
+ $this->assertSame('value3', $transport->getParam('param3'));
+ }
+}