Skip to content

Commit

Permalink
Fixed test that was never supposed to work
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 24, 2016
1 parent a2ac7da commit abf063e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 25 deletions.
11 changes: 9 additions & 2 deletions tests/TestCase/Console/ShellTest.php
Expand Up @@ -962,7 +962,11 @@ public function testRunCommandWithMissingMethodInSubcommands()
*/
public function testRunCommandBaseclassMethod()
{
$shell = $this->getMock('Cake\Console\Shell', ['startup', 'getOptionParser', 'out'], [], '', false);
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['startup', 'getOptionParser', 'out', 'hr'])
->disableOriginalConstructor()
->getMock();

$shell->io($this->getMock('Cake\Console\ConsoleIo'));
$parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false);

Expand All @@ -982,7 +986,10 @@ public function testRunCommandBaseclassMethod()
*/
public function testRunCommandMissingMethod()
{
$shell = $this->getMock('Cake\Console\Shell', ['startup', 'getOptionParser', 'out'], [], '', false);
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['startup', 'getOptionParser', 'out', 'hr'])
->disableOriginalConstructor()
->getMock();
$shell->io($this->getMock('Cake\Console\ConsoleIo'));
$parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false);

Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/Controller/Component/AuthComponentTest.php
Expand Up @@ -1450,6 +1450,7 @@ public function testStatelessAuthNoRedirect()
*/
public function testStatelessFollowedByStatefulAuth()
{
$this->Auth->response = $this->getMock('Cake\Network\Response', ['stop', 'statusCode', 'send']);
$event = new Event('Controller.startup', $this->Controller);
$this->Auth->authenticate = ['Basic', 'Form'];
$this->Controller->request['action'] = 'add';
Expand Down
24 changes: 6 additions & 18 deletions tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -522,29 +522,17 @@ public function testRedirectBeforeRedirectModifyingStatusCode()
$this->assertEquals(302, $response->statusCode());
}

/**
* test that beforeRedirect callback returning false in controller
*
* @return void
*/
public function testRedirectBeforeRedirectListenerReturnFalse()
public function testRedirectBeforeRedirectListenerReturnResponse()
{
$Response = $this->getMock('Cake\Network\Response', ['stop', 'header']);
$Response = $this->getMock('Cake\Network\Response', ['stop', 'header', 'statusCode']);
$Controller = new Controller(null, $Response);

$Controller->eventManager()->attach(function ($event, $url, $response) {
return false;
}, 'Controller.beforeRedirect');

$Controller->response->expects($this->never())
->method('stop');
$Controller->response->expects($this->never())
->method('header');
$Controller->response->expects($this->never())
->method('statusCode');
$Controller->eventManager()->on('Controller.beforeRedirect', function ($event, $url, $response) {
return new Response;
});

$result = $Controller->redirect('http://cakephp.org');
$this->assertNull($result);
$this->assertInstanceOf(Response::class, $result);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/BelongsToTest.php
Expand Up @@ -287,7 +287,7 @@ public function testCascadeDelete()
*/
public function testSaveAssociatedOnlyEntities()
{
$mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
$mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false);
$config = [
'sourceTable' => $this->client,
'targetTable' => $mock,
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/HasManyTest.php
Expand Up @@ -485,7 +485,7 @@ public function testCascadeDeleteCallbacks()
*/
public function testSaveAssociatedOnlyEntities()
{
$mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
$mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false);
$config = [
'sourceTable' => $this->author,
'targetTable' => $mock,
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/HasOneTest.php
Expand Up @@ -221,7 +221,7 @@ public function testAttachToMultiPrimaryKeyMistmatch()
*/
public function testSaveAssociatedOnlyEntities()
{
$mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
$mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false);
$config = [
'sourceTable' => $this->user,
'targetTable' => $mock,
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/EntityTest.php
Expand Up @@ -818,7 +818,7 @@ public function testConstructorWithClean()
public function testConstructorWithMarkNew()
{
$entity = $this->getMockBuilder('\Cake\ORM\Entity')
->setMethods(['isNew'])
->setMethods(['isNew', 'clean'])
->disableOriginalConstructor()
->getMock();
$entity->expects($this->never())->method('clean');
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Routing/Filter/AssetFilterTest.php
Expand Up @@ -76,7 +76,7 @@ public function testNotModified()
$this->assertEquals(200, $response->statusCode());
$this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());

$response = $this->getMock('Cake\Network\Response', ['_sendHeader', 'checkNotModified']);
$response = $this->getMock('Cake\Network\Response', ['_sendHeader', 'checkNotModified', 'send']);
$request = new Request('test_theme/img/cake.power.gif');

$response->expects($this->once())->method('checkNotModified')
Expand Down

0 comments on commit abf063e

Please sign in to comment.