Skip to content
Permalink
Browse files

Refactor input() tests to not rely on protected methods

Decouple the tests from the implementation so changing the code is
easier.
  • Loading branch information...
markstory committed Sep 8, 2016
1 parent 50a6672 commit 0010c72f95d2f989c08dbfd8c83371b34f03ae13
Showing with 18 additions and 16 deletions.
  1. +18 −16 tests/TestCase/Network/RequestTest.php
@@ -2573,12 +2573,9 @@ public function testSetInput()
*/
public function testInput()
{
$request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['_readInput'])
->getMock();
$request->expects($this->once())->method('_readInput')
->will($this->returnValue('I came from stdin'));
$request = new Request([
'input' => 'I came from stdin'
]);
$result = $request->input();
$this->assertEquals('I came from stdin', $result);
}
@@ -2590,11 +2587,9 @@ public function testInput()
*/
public function testInputDecode()
{
$request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['_readInput'])
->getMock();
$request->expects($this->once())->method('_readInput')
->will($this->returnValue('{"name":"value"}'));
$request = new Request([
'input' => '{"name":"value"}'
]);
$result = $request->input('json_decode');
$this->assertEquals(['name' => 'value'], (array)$result);
@@ -2614,11 +2609,9 @@ public function testInputDecodeExtraParams()
</post>
XML;
$request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['_readInput'])
->getMock();
$request->expects($this->once())->method('_readInput')
->will($this->returnValue($xml));
$request = new Request([
'input' => $xml
]);
$result = $request->input('Cake\Utility\Xml::build', ['return' => 'domdocument']);
$this->assertInstanceOf('DOMDocument', $result);
@@ -2628,6 +2621,15 @@ public function testInputDecodeExtraParams()
);
}
/**
* Test getBody
*
* @return void
*/
public function testGetBody()
{
}
/**
* Test is('requested') and isRequested()
*

0 comments on commit 0010c72

Please sign in to comment.
You can’t perform that action at this time.