Beispiel #1
0
 function testGenerateHelperFunctions()
 {
     $name = 'namespaced_name';
     $Route = new AkRoute('/author/:name');
     AkRouterHelper::generateHelperFunctionsFor($name, $Route);
     $this->assertTrue(function_exists('namespaced_name_url'));
     $this->assertTrue(function_exists('namespaced_name_path'));
 }
Beispiel #2
0
 public function connectNamed($name, $url_pattern = '', $defaults = array(), $requirements = array(), $conditions = array())
 {
     $this->_logNamedRoute($name);
     $this->handleApiShortcuts($url_pattern, $defaults, $requirements);
     if (isset($defaults['conditions'])) {
         throw new Exception('Could not connect named route with conditions');
     }
     $Route = new AkRoute($url_pattern, $defaults, $requirements, $conditions);
     if ($this->generate_helper_functions && !empty($name)) {
         AkRouterHelper::generateHelperFunctionsFor($name, $Route);
     }
     return $this->addRoute($name, $Route);
 }
Beispiel #3
0
            $multiple_expected_php .= $expected_php;
        }
        $AkSintags = new AkSintagsParser();
        $php = $AkSintags->parse($sintags);
        if ($php != $expected_php) {
            $test_results['errors'][] = " FAILED!\n" . "\n-------\nWith Sintags: \n" . $sintags . "\n" . "\n-------\ngenerated: \n" . $php . "\n" . "\n-------\nwhile expected: \n" . $expected_php . "\n-------------\n";
        } else {
            $test_results['success'][] = $sintags;
        }
    }
    if ($all_in_one_test) {
        $AkSintags = new AkSintagsParser();
        $php = $AkSintags->parse($multiple_sintags);
        if ($php != $multiple_expected_php) {
            $test_results['errors'][] = " FAILED!\n" . "\n-------\nWith Sintags: \n" . $multiple_sintags . "\n" . "\n-------\ngenerated: \n" . $php . "\n" . "\n-------\nwhile expected: \n" . $multiple_expected_php . "\n-------------\n";
        } else {
            $test_results['success'][] = $sintags;
        }
    }
}
_run_from_file('sintags_blocks_data.txt');
_run_from_file('sintags_test_data.txt');
AkRouterHelper::generateHelperFunctionsFor('named_route', new AkRoute('/'));
_run_from_file('sintags_helpers_data.txt');
echo "\nRunning Sintags tests\n";
echo count((array) @$test_results['success']) . " tests passed\n";
if (!empty($test_results['errors'])) {
    echo join("\n", $test_results['errors']);
    echo count($test_results['errors']) . " failure/s!!!";
}
echo "\nCompleted running tests.\n";
Beispiel #4
0
 private function connectNamed($name, $url_pattern, $defaults = array(), $requirements = array(), $conditions = array())
 {
     $this->handleApiShortcuts($url_pattern, $defaults, $requirements);
     $Route = new AkRoute($url_pattern, $defaults, $requirements, $conditions);
     if ($this->generate_helper_functions) {
         AkRouterHelper::generateHelperFunctionsFor($name, $Route);
     }
     return $this->addRoute($name, $Route);
 }
Beispiel #5
0
 public function test_sintags_helpers()
 {
     AkRouterHelper::generateHelperFunctionsFor('named_route', $this->mock('AkRoute'));
     $this->_run_from_file('sintags_helpers_data.txt');
 }