|
class BottomNavTest extends PHPUnit_Framework_Testcase |
|
{ |
|
public function test_buttons_are_constructed_from_php_config_and_have_the_given_order() |
|
{ |
|
// Defined in JSON, mocked here |
|
|
|
$buttonOrder = ['home', 'pages', 'pierce', 'map', 'on-scene']; |
|
|
|
|
|
// Configuration for buttons lives in PHP for now |
|
|
|
$buttonConfig = [ |
|
['identifier' => 'pierce', 'target' => '#control'], |
|
['identifier' => 'home', 'target' => '#home'], |
|
['identifier' => 'pages', 'target' => '#'], |
|
['identifier' => 'on-scene', 'target' => '#on-scene'], |
|
['identifier' => 'map', 'target' => '#'] |
|
]; |
|
|
|
|
|
// Construct the bottom navigation bar with button configuration data |
|
|
|
$BottomNav = new BottomNav($buttonConfig); |
|
|
|
|
|
// Manually define the expected result - an array of BottomNavButtons in the correct order |
|
|
|
$expectedResult = [ |
|
new BottomNavButton('home', '#home'), |
|
new BottomNavButton('pages', '#'), |
|
new BottomNavButton('pierce', '#control'), |
|
new BottomNavButton('map', '#'), |
|
new BottomNavButton('on-scene', '#on-scene') |
|
]; |
|
|
|
|
|
// Obtain the actual result we want to compare against - a list of buttons ordered by the given order |
|
|
|
$actualResult = $BottomNav->getButtons($buttonOrder); |
|
|
|
|
|
// Make the assertion - if they are the same, test passes. |
|
|
|
$this->assertSame($expectedResult, $actualResult); |
|
} |
|
|
|
|
|
public function test_buttons_are_constructed_from_json_config_and_have_the_given_order() |
|
{ |
|
// repeat the test, but with data source from JSON config |
|
|
|
$this->assertSame($expectedResult, $actualResult); |
|
} |
|
} |