3 require_once('_HelpersUnitTester.php');
4 require_once(AK_LIB_DIR
.DS
.'AkActionView'.DS
.'helpers'.DS
.'menu_helper.php');
5 require_once(AK_LIB_DIR
.DS
.'AkActionController.php');
6 require_once(AK_LIB_DIR
.DS
.'AkRequest.php');
7 require_once(AK_CONTROLLERS_DIR
.DS
.'..'.DS
.'application_controller.php');
9 ak_generate_mock('AkRequest');
11 class MenuHelperTests
extends HelpersUnitTester
15 $this->controller
= &new AkActionController();
16 $this->controller
->Request
=& new MockAkRequest($this);
17 $this->controller
->controller_name
= 'test';
18 $this->controller
->instantiateHelpers();
20 $this->menu_helper
=& $this->controller
->menu_helper
;
23 function test_should_get_controller_methods()
25 $controller_file_name = 'authentication_controller.php';
26 require_once(AK_CONTROLLERS_DIR
.DS
.$controller_file_name);
27 $this->assertTrue(in_array('authenticate',$this->menu_helper
->_get_this_class_methods('AuthenticationController')));
30 function test_should_get_all_controllers_with_their_actions()
32 $available_controllers = (array)Ak
::dir(AK_CONTROLLERS_DIR
, array('dirs'=>false));
33 $got = $this->menu_helper
->_get_default_full_menu();
34 foreach ($available_controllers as $controller_filename){
35 $controller_name = str_replace('_controller.php','',$controller_filename);
36 $this->assertTrue(isset($got[$controller_name]));
38 $this->assertTrue(in_array('authenticate',$got['authentication']));
41 function tests_menu_for_controllers()
45 $this->menu_helper
->menu_for_controllers(array('advertiser' => array('buy', 'partial_in_template'), 'locale_detection' => 'session', 'page' => 'setup')),
46 file_get_contents(AK_TEST_HELPERS_DIR
.DS
.'menu_helper_limit.txt')
50 $this->menu_helper
->menu_for_controllers(array('unavailable' => array('foo', 'bar'))),
51 '<div id="menu"></div>'
55 $this->menu_helper
->menu_for_controllers(array('unavailable' => array('foo', 'bar')), "custom_menu_id"),
56 '<div id="custom_menu_id"></div>'
60 $this->menu_helper
->menu_for_controllers(array('advertiser' => array('buy', 'partial_in_template'), 'locale_detection' => 'session', 'page' => 'setup'), 'menu', 'current', ''),
61 file_get_contents(AK_TEST_HELPERS_DIR
.DS
.'menu_helper_limit_no_title_tag.txt')
65 $this->menu_helper
->menu_for_controllers(array('advertiser' => array('buy', 'partial_in_template'), 'locale_detection' => 'session', 'page' => 'setup'), 'menu', 'current', 'p'),
66 file_get_contents(AK_TEST_HELPERS_DIR
.DS
.'menu_helper_limit_title_tag_p.txt')
69 $this->controller
->controller_name
= 'Advertiser';
72 $this->menu_helper
->menu_for_controllers(array('advertiser' => array('buy', 'partial_in_template'), 'locale_detection' => 'session', 'page' => 'setup')),
73 file_get_contents(AK_TEST_HELPERS_DIR
.DS
.'menu_helper_limit_current.txt')
77 $this->menu_helper
->menu_for_controllers(array('advertiser' => array('buy', 'partial_in_template'), 'locale_detection' => 'session', 'page' => 'setup'), 'menu', 'selected'),
78 file_get_contents(AK_TEST_HELPERS_DIR
.DS
.'menu_helper_limit_current_not_default.txt')
82 $this->menu_helper
->menu_for_controllers(array('advertiser' => array('buy', 'partial_in_template'), 'locale_detection' => 'session', 'page' => 'setup'), 'menu', 'selected', ''),
83 file_get_contents(AK_TEST_HELPERS_DIR
.DS
.'menu_helper_limit_current_not_default_no_title.txt')
90 ak_test('MenuHelperTests');