function _run_from_file($file_name, $all_in_one_test = true) { global $test_results; $multiple_expected_php = $multiple_sintags = ''; $tests = explode('===================================', file_get_contents(TESTING_BASE_DIR . DS . 'fixtures' . DS . $file_name)); foreach ($tests as $test) { list($sintags, $php) = explode('-----------------------------------', $test); $sintags = trim($sintags); $expected_php = trim($php); if (empty($sintags)) { return; } else { $multiple_sintags .= $sintags; $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; } } }
public function _run_from_file($file_name, $all_in_one_test = true) { $multiple_expected_php = $multiple_sintags = ''; $tests = explode('===================================', file_get_contents(AK_TEST_DIR . DS . 'fixtures' . DS . 'data' . DS . $file_name)); foreach ($tests as $test) { list($sintags, $php) = explode('-----------------------------------', $test); $sintags = trim($sintags); $expected_php = trim($php); if (empty($sintags)) { break; } else { $multiple_sintags .= $sintags; $multiple_expected_php .= $expected_php; } $AkSintags = new AkSintagsParser(); $php = $AkSintags->parse($sintags); if ($php != $expected_php) { Ak::trace("GENERATED: \n" . $php); Ak::trace("EXPECTED: \n" . $expected_php); Ak::trace("SINTAGS: \n" . $sintags); } $this->assertEqual($php, $expected_php); } if ($all_in_one_test) { $AkSintags = new AkSintagsParser(); $php = $AkSintags->parse($multiple_sintags); if ($php != $multiple_expected_php) { Ak::trace("GENERATED: \n" . $php); Ak::trace("EXPECTED: \n" . $expected_php); Ak::trace("SINTAGS: \n" . $sintags); } $this->assertEqual($php, $multiple_expected_php); } }