Open Journal Systems  3.3.0
PreComputedInflectorTest.php
1 <?php
2 
4 
6 
11 {
12  public function testUsesPreComputedHash()
13  {
14  $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
15  $mock->expects($this->once())->method('snake')->with('Test')->will($this->returnValue('test'));
16  $mock->expects($this->once())->method('camel')->with('Test')->will($this->returnValue('Test'));
17  $inflector = new PreComputedInflector($mock, array('FooBar' => 'foo_bar'), array('foo_bar' => 'FooBar'));
18  $this->assertEquals('FooBar', $inflector->camel('foo_bar'));
19  $this->assertEquals('foo_bar', $inflector->snake('FooBar'));
20  $this->assertEquals('Test', $inflector->camel('Test'));
21  $this->assertEquals('test', $inflector->snake('Test'));
22  }
23 
24  public function testMirrorsPrecomputedValues()
25  {
26  $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
27  $mock->expects($this->never())->method('snake');
28  $mock->expects($this->never())->method('camel');
29  $inflector = new PreComputedInflector($mock, array('Zeep' => 'zeep'), array(), true);
30  $this->assertEquals('Zeep', $inflector->camel('zeep'));
31  $this->assertEquals('zeep', $inflector->snake('Zeep'));
32  }
33 
35  {
36  $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
37  $mock->expects($this->never())->method('snake');
38  $mock->expects($this->never())->method('camel');
39  $inflector = new PreComputedInflector($mock, array('Zeep' => 'zeep'), array('foo' => 'Foo'), true);
40  $this->assertEquals('Zeep', $inflector->camel('zeep'));
41  $this->assertEquals('zeep', $inflector->snake('Zeep'));
42  $this->assertEquals('Foo', $inflector->camel('foo'));
43  $this->assertEquals('foo', $inflector->snake('Foo'));
44  }
45 }
Guzzle\Inflection\PreComputedInflector
Definition: PreComputedInflector.php:8
Guzzle\Tests\GuzzleTestCase
Definition: GuzzleTestCase.php:22
Guzzle\Tests\Inflection\PreComputedInflectorTest
Definition: PreComputedInflectorTest.php:10
Guzzle\Tests\Inflection\PreComputedInflectorTest\testMirrorsPrecomputedValues
testMirrorsPrecomputedValues()
Definition: PreComputedInflectorTest.php:24
Guzzle\Tests\Inflection\PreComputedInflectorTest\testMirrorsPrecomputedValuesByMerging
testMirrorsPrecomputedValuesByMerging()
Definition: PreComputedInflectorTest.php:34
Guzzle\Tests\Inflection
Definition: InflectorTest.php:3
Guzzle\Tests\Inflection\PreComputedInflectorTest\testUsesPreComputedHash
testUsesPreComputedHash()
Definition: PreComputedInflectorTest.php:12