Skip to content

Commit 6f6f284

Browse files
author
Dave
committed
tests
1 parent f76a151 commit 6f6f284

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

build/tests/phpunit/RPSNewCoreControlClassTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,31 @@ class RPSNewCoreControlClassTest extends PHPUnit_Framework_TestCase {
66

77
public function setUp() {
88
require_once("bootstrap.php");
9-
$this->availableControls = array("Game", "Page");
9+
$this->availableControls = array("Game");
1010
}
1111

1212
public function testexecuteControlReturnsAnArray() {
13+
14+
$mockPageVars = array();
15+
$mockPageVars["route"] = array();
16+
$mockPageVars["route"]["action"] = "home";
17+
1318
$control = new Core\Control() ;
1419
foreach ($this->availableControls as $availableControl) {
15-
$currentControlOutput = $control->executeControl($availableControl, array() );
20+
$currentControlOutput = $control->executeControl($availableControl, $mockPageVars);
1621
$this->assertTrue( is_array($currentControlOutput) );
1722
}
1823
}
1924

2025
public function testexecuteControlReturnsAnArrayOfCorrectStructure() {
26+
27+
$mockPageVars = array();
28+
$mockPageVars["route"] = array();
29+
$mockPageVars["route"]["action"] = "home";
30+
2131
$control = new Core\Control() ;
2232
foreach ($this->availableControls as $availableControl) {
23-
$currentControlOutput = $control->executeControl($availableControl, array());
33+
$currentControlOutput = $control->executeControl($availableControl, $mockPageVars );
2434
$this->assertTrue( array_key_exists("view", $currentControlOutput) );
2535
$this->assertTrue( array_key_exists("pageVars", $currentControlOutput) );
2636
}

build/tests/phpunit/RPSNewCoreViewClassTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ public function setUp() {
1111
$this->listOfViews = array("index", "login", "register");
1212
$this->viewVars = array(
1313
"view"=>"index",
14-
"pageVars"=>array()
15-
);
14+
"pageVars"=>array() );
1615
$this->executeViewStoreTheOutput();
1716
}
1817

src/Controller/Game.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
class Game extends Base {
66

77
public function execute($pageVars) {
8-
var_dump($pageVars);
98
if ( $pageVars["route"]["action"] == "home" ) {
109
return array ("type"=>"view", "view"=>"gameIntro", "pageVars"=>$this->content); }
1110
if ( $pageVars["route"]["action"] == "choosePlayers" ) {
@@ -15,7 +14,6 @@ public function execute($pageVars) {
1514
$this->processGame();
1615
return array ("type"=>"view", "view"=>"gameComplete", "pageVars"=>$this->content); }
1716
return array ("type"=>"view", "view"=>"gameChoosePlayers", "pageVars"=>$this->content); }
18-
echo "im here";
1917
return array ("type"=>"view", "view"=>"gameIntro", "pageVars"=>$this->content);
2018
}
2119

src/Core/Control.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public function executeControl($control, $pageVars) {
88
$className = '\\Controller\\'.ucfirst($control);
99
$controlObject = new $className;
1010
$executionResult = $controlObject->execute($pageVars);
11-
var_dump ( "x res", $executionResult);
1211
return $executionResult;
1312
}
1413

src/Model/PageFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function getPageModel($page) {
1111

1212
private function getModelNameFromPage($page) {
1313
$pages = array("full-cv"=>"FullCV", "juicy-bits"=>"JuicyCV", "hi"=>"Hi" );
14-
$modelName = $pages[$page];
14+
$modelName = (isset($pages[$page])) ? $pages[$page] : null;
1515
$className = "\Model\\".$modelName.'Page' ;
1616
return new $className;
1717
}

0 commit comments

Comments
 (0)