3 // Copyright (c) 2011 Blue Static
5 // This program is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or any later version.
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 // You should have received a copy of the GNU General Public License along with
15 // this program. If not, see <http://www.gnu.org/licenses/>.
17 namespace hoplite\test
;
18 use hoplite\http
as http
;
20 require_once HOPLITE_ROOT
. '/http/action_controller.php';
22 class TestActionController
extends http\ActionController
24 public $did_action = FALSE;
26 public function ActionSomething(http\Request
$request, http\Response
$response)
28 $this->did_action
= TRUE;
32 class ActionControllerTest
extends \PHPUnit_Framework_TestCase
34 public function setUp()
37 $this->fixture
= new TestActionController(new http\
RootController($globals));
38 $this->request
= new http\
Request();
39 $this->response
= new http\
Response();
42 public function testDispatch()
44 $this->request
->data
['action'] = 'something';
45 $this->fixture
->Invoke($this->request
, $this->response
);
46 $this->assertTrue($this->fixture
->did_action
);
49 public function testFailedDispatch()
52 $mock = $this->getMock('hoplite\http\RootController', array(), array($globals));
53 $this->fixture
= new TestActionController($mock);
55 $mock->expects($this->once())
58 $this->request
->data
['action'] = 'nothing';
59 $this->fixture
->Invoke($this->request
, $this->response
);
60 $this->assertFalse($this->fixture
->did_action
);