-
-
Save beez/6f9ee89538d1a6be6dfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App::uses('ChannelsController', 'Epg.Controller'); | |
class ChannelsControllerTest extends ControllerTestCase { | |
public function setUp() { | |
parent::setUp(); | |
$this->Controller = $this->generate('Epg.Channels', ['components' => ['Auth' => ['_apiLoginRequest']]]); | |
$httpSocketResponseBody = new HttpSocketResponse(); | |
$httpSocketResponseBody->code = 200; | |
$httpSocketResponseBody->body = '{"UserLogin": "UserOne"}'; | |
$this->Controller->Auth | |
->expects($this->any()) | |
->method('_apiLoginRequest') | |
->will($this->returnValue($httpSocketResponseBody)); | |
} | |
} | |
public function testViewChannel() { | |
var_dump($this->Controller->Auth->_apiLoginRequest()); // Uses the mock and dumps "['body' => '{"UserLogin": "UserOne"}']" | |
$result = $this->testAction('/channels/view/2.json', ['method' => 'GET']); // Doesn't uses the mock and therefore gets an error from the auth component | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment