Skip to content

Commit

Permalink
Fixing session usage in ControllerTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 18, 2014
1 parent d68d5d5 commit abddd99
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/TestSuite/ControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Cake\Core\App;
use Cake\Error;
use Cake\Event\Event;
use Cake\Network\Session;
use Cake\Routing\DispatcherFactory;
use Cake\Routing\DispatcherFilter;
use Cake\Routing\Router;
Expand Down Expand Up @@ -246,6 +247,7 @@ protected function _testAction($url = '', $options = array()) {
'url' => $url,
'cookies' => $options['cookies'],
'query' => $options['query'],
'session' => new Session()
);
if (is_array($options['data'])) {
$requestData['post'] = $options['data'];
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCase/Routing/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Cake\Event\Event;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Network\Session;
use Cake\Routing\Dispatcher;
use Cake\Routing\Filter\ControllerFactoryFilter;
use Cake\Routing\Router;
Expand Down Expand Up @@ -473,7 +474,8 @@ public function testAfterDispatchReplaceResponse() {
'controller' => 'posts',
'action' => 'index',
'pass' => [],
]
],
'session' => new Session
]);
$this->dispatcher->addFilter($filter);
$this->dispatcher->dispatch($request, $response);
Expand Down
6 changes: 0 additions & 6 deletions tests/TestCase/TestSuite/ControllerTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,12 @@ public function testGenerate() {
'models' => array('Posts'),
'components' => array(
'RequestHandler' => array('isPut'),
'Session'
)
));
$Posts->RequestHandler->expects($this->once())
->method('isPut')
->will($this->returnValue(true));
$this->assertTrue($Posts->RequestHandler->isPut());

$Posts->Auth->Session->expects($this->any())
->method('write')
->will($this->returnValue('written!'));
$this->assertEquals('written!', $Posts->Auth->Session->write('something'));
}

/**
Expand Down

0 comments on commit abddd99

Please sign in to comment.