Skip to content

Commit

Permalink
Remove use of TestCase::getMock() from "Network" namepace tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jun 5, 2016
1 parent 029f041 commit 07e390b
Show file tree
Hide file tree
Showing 5 changed files with 322 additions and 182 deletions.
7 changes: 3 additions & 4 deletions tests/TestCase/Network/Http/Adapter/StreamTest.php
Expand Up @@ -100,10 +100,9 @@ class StreamTest extends TestCase
public function setUp()
{
parent::setUp();
$this->stream = $this->getMock(
'Cake\Network\Http\Adapter\Stream',
['_send']
);
$this->stream = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['_send'])
->getMock();
stream_wrapper_register('cakephp', __NAMESPACE__ . '\CakeStreamWrapper');
}

Expand Down
7 changes: 3 additions & 4 deletions tests/TestCase/Network/Http/Auth/DigestTest.php
Expand Up @@ -33,10 +33,9 @@ public function setUp()
{
parent::setUp();

$this->client = $this->getMock(
'Cake\Network\Http\Client',
['send']
);
$this->client = $this->getMockBuilder('Cake\Network\Http\Client')
->setMethods(['send'])
->getMock();
$this->auth = new Digest($this->client);
}

Expand Down
51 changes: 36 additions & 15 deletions tests/TestCase/Network/Http/ClientTest.php
Expand Up @@ -167,7 +167,9 @@ public function testGetSimpleWithHeadersAndCookies()
'split' => 'value'
];

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->once())
->method('send')
->with($this->logicalAnd(
Expand Down Expand Up @@ -196,7 +198,9 @@ public function testGetQuerystring()
{
$response = new Response();

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->once())
->method('send')
->with($this->logicalAnd(
Expand Down Expand Up @@ -226,7 +230,9 @@ public function testGetQuerystringString()
{
$response = new Response();

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->once())
->method('send')
->with($this->logicalAnd(
Expand Down Expand Up @@ -257,7 +263,9 @@ public function testGetWithContent()
{
$response = new Response();

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->once())
->method('send')
->with($this->logicalAnd(
Expand Down Expand Up @@ -286,7 +294,9 @@ public function testGetWithContent()
*/
public function testInvalidAuthenticationType()
{
$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->never())
->method('send');

Expand All @@ -308,7 +318,9 @@ public function testGetWithAuthenticationAndProxy()
{
$response = new Response();

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$headers = [
'Connection' => 'close',
'User-Agent' => 'CakePHP',
Expand Down Expand Up @@ -363,7 +375,9 @@ public function testMethodsSimple($method)
{
$response = new Response();

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->once())
->method('send')
->with($this->logicalAnd(
Expand Down Expand Up @@ -413,7 +427,9 @@ public function testPostWithTypeKey($type, $mime)
'Accept' => $mime,
];

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->once())
->method('send')
->with($this->logicalAnd(
Expand Down Expand Up @@ -445,7 +461,9 @@ public function testPostWithStringDataDefaultsToFormEncoding()
'Content-Type' => 'application/x-www-form-urlencoded',
];

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->any())
->method('send')
->with($this->logicalAnd(
Expand All @@ -471,7 +489,9 @@ public function testPostWithStringDataDefaultsToFormEncoding()
*/
public function testExceptionOnUnknownType()
{
$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->never())
->method('send');

Expand All @@ -489,10 +509,9 @@ public function testExceptionOnUnknownType()
*/
public function testCookieStorage()
{
$adapter = $this->getMock(
'Cake\Network\Http\Adapter\Stream',
['send']
);
$adapter = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$cookieJar = $this->getMockBuilder('Cake\Network\Http\CookieCollection')->getMock();

$headers = [
Expand Down Expand Up @@ -533,7 +552,9 @@ public function testHeadQuerystring()
{
$response = new Response();

$mock = $this->getMock('Cake\Network\Http\Adapter\Stream', ['send']);
$mock = $this->getMockBuilder('Cake\Network\Http\Adapter\Stream')
->setMethods(['send'])
->getMock();
$mock->expects($this->once())
->method('send')
->with($this->logicalAnd(
Expand Down
12 changes: 9 additions & 3 deletions tests/TestCase/Network/RequestTest.php
Expand Up @@ -2314,7 +2314,9 @@ public function testSetInput()
*/
public function testInput()
{
$request = $this->getMock('Cake\Network\Request', ['_readInput']);
$request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['_readInput'])
->getMock();
$request->expects($this->once())->method('_readInput')
->will($this->returnValue('I came from stdin'));

Expand All @@ -2329,7 +2331,9 @@ public function testInput()
*/
public function testInputDecode()
{
$request = $this->getMock('Cake\Network\Request', ['_readInput']);
$request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['_readInput'])
->getMock();
$request->expects($this->once())->method('_readInput')
->will($this->returnValue('{"name":"value"}'));

Expand All @@ -2351,7 +2355,9 @@ public function testInputDecodeExtraParams()
</post>
XML;

$request = $this->getMock('Cake\Network\Request', ['_readInput']);
$request = $this->getMockBuilder('Cake\Network\Request')
->setMethods(['_readInput'])
->getMock();
$request->expects($this->once())->method('_readInput')
->will($this->returnValue($xml));

Expand Down

0 comments on commit 07e390b

Please sign in to comment.