Skip to content

Commit

Permalink
Add deprecated warning for deprecated method.
Browse files Browse the repository at this point in the history
Fix failing tests.
  • Loading branch information
markstory committed Sep 15, 2014
1 parent 3f110d0 commit 5d203b4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/Controller/Controller.php
Expand Up @@ -454,6 +454,10 @@ public function implementedEvents() {
* @return void
*/
public function constructClasses() {
trigger_error(
'Controller::constructClasses() is deprecated and will be removed in the first RC release',
E_USER_DEPRECATED
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Controller/Component/AuthComponentTest.php
Expand Up @@ -819,7 +819,7 @@ public function testForbiddenException() {
*/
public function testNoRedirectOnLoginAction() {
$event = new Event('Controller.startup', $this->Controller);
$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->methods = array('login');

$url = '/AuthTest/login';
Expand Down
18 changes: 9 additions & 9 deletions tests/TestCase/Controller/Component/CsrfComponentTest.php
Expand Up @@ -34,7 +34,7 @@ class CsrfComponentTest extends TestCase {
public function setUp() {
parent::setUp();

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$this->registry = new ComponentRegistry($controller);
$this->component = new CsrfComponent($this->registry);
}
Expand All @@ -57,7 +57,7 @@ public function tearDown() {
public function testSettingCookie() {
$_SERVER['REQUEST_METHOD'] = 'GET';

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request(['base' => '/dir']);
$controller->response = new Response();

Expand Down Expand Up @@ -94,7 +94,7 @@ public function testValidTokenInHeader($method) {
$_SERVER['REQUEST_METHOD'] = $method;
$_SERVER['HTTP_X_CSRF_TOKEN'] = 'testing123';

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request(['cookies' => ['csrfToken' => 'testing123']]);
$controller->response = new Response();

Expand All @@ -114,7 +114,7 @@ public function testInvalidTokenInHeader($method) {
$_SERVER['REQUEST_METHOD'] = $method;
$_SERVER['HTTP_X_CSRF_TOKEN'] = 'nope';

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request([
'cookies' => ['csrfToken' => 'testing123']
]);
Expand All @@ -133,7 +133,7 @@ public function testInvalidTokenInHeader($method) {
public function testValidTokenRequestData($method) {
$_SERVER['REQUEST_METHOD'] = $method;

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request([
'post' => ['_csrfToken' => 'testing123'],
'cookies' => ['csrfToken' => 'testing123']
Expand All @@ -155,7 +155,7 @@ public function testValidTokenRequestData($method) {
public function testInvalidTokenRequestData($method) {
$_SERVER['REQUEST_METHOD'] = $method;

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request([
'post' => ['_csrfToken' => 'nope'],
'cookies' => ['csrfToken' => 'testing123']
Expand All @@ -174,7 +174,7 @@ public function testInvalidTokenRequestData($method) {
public function testCsrfValidationSkipsRequestAction() {
$_SERVER['REQUEST_METHOD'] = 'POST';

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request([
'params' => ['requested' => 1],
'post' => ['_csrfToken' => 'nope'],
Expand All @@ -196,7 +196,7 @@ public function testCsrfValidationSkipsRequestAction() {
public function testConfigurationCookieCreate() {
$_SERVER['REQUEST_METHOD'] = 'GET';

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request(['base' => '/dir']);
$controller->response = new Response();

Expand Down Expand Up @@ -226,7 +226,7 @@ public function testConfigurationCookieCreate() {
public function testConfigurationValidate() {
$_SERVER['REQUEST_METHOD'] = 'POST';

$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$controller->request = new Request([
'cookies' => ['csrfToken' => 'nope', 'token' => 'yes'],
'post' => ['_csrfToken' => 'no match', 'token' => 'yes'],
Expand Down
Expand Up @@ -97,7 +97,7 @@ public function testConstructorConfig() {
$config = array(
'viewClassMap' => array('json' => 'MyPlugin.MyJson')
);
$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$collection = new ComponentRegistry($controller);
$requestHandler = new RequestHandlerComponent($collection, $config);
$this->assertEquals(array('json' => 'MyPlugin.MyJson'), $requestHandler->config('viewClassMap'));
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Helper/HtmlHelperTest.php
Expand Up @@ -63,7 +63,7 @@ class HtmlHelperTest extends TestCase {
*/
public function setUp() {
parent::setUp();
$controller = $this->getMock('Cake\Controller\Controller');
$controller = $this->getMock('Cake\Controller\Controller', ['redirect']);
$this->View = $this->getMock('Cake\View\View', array('append'));
$this->Html = new HtmlHelper($this->View);
$this->Html->request = new Request();
Expand Down

0 comments on commit 5d203b4

Please sign in to comment.