summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php')
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php
new file mode 100644
index 0000000..ff2654c
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Guzzle\Tests\Inflection;
+
+use Guzzle\Inflection\PreComputedInflector;
+
+/**
+ * @covers Guzzle\Inflection\PreComputedInflector
+ */
+class PreComputedInflectorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testUsesPreComputedHash()
+ {
+ $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
+ $mock->expects($this->once())->method('snake')->with('Test')->will($this->returnValue('test'));
+ $mock->expects($this->once())->method('camel')->with('Test')->will($this->returnValue('Test'));
+ $inflector = new PreComputedInflector($mock, array('FooBar' => 'foo_bar'), array('foo_bar' => 'FooBar'));
+ $this->assertEquals('FooBar', $inflector->camel('foo_bar'));
+ $this->assertEquals('foo_bar', $inflector->snake('FooBar'));
+ $this->assertEquals('Test', $inflector->camel('Test'));
+ $this->assertEquals('test', $inflector->snake('Test'));
+ }
+
+ public function testMirrorsPrecomputedValues()
+ {
+ $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
+ $mock->expects($this->never())->method('snake');
+ $mock->expects($this->never())->method('camel');
+ $inflector = new PreComputedInflector($mock, array('Zeep' => 'zeep'), array(), true);
+ $this->assertEquals('Zeep', $inflector->camel('zeep'));
+ $this->assertEquals('zeep', $inflector->snake('Zeep'));
+ }
+
+ public function testMirrorsPrecomputedValuesByMerging()
+ {
+ $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
+ $mock->expects($this->never())->method('snake');
+ $mock->expects($this->never())->method('camel');
+ $inflector = new PreComputedInflector($mock, array('Zeep' => 'zeep'), array('foo' => 'Foo'), true);
+ $this->assertEquals('Zeep', $inflector->camel('zeep'));
+ $this->assertEquals('zeep', $inflector->snake('Zeep'));
+ $this->assertEquals('Foo', $inflector->camel('foo'));
+ $this->assertEquals('foo', $inflector->snake('Foo'));
+ }
+}