/** * Enables annotation support in a script file. */ public static function enable() { // make sure that annotations are not replaced twice at the same time if (!self::$enabled) { self::$enabled = true; $support = new LimeAnnotationSupport(self::getScriptPath()); $support->execute(); exit; } }
<?php /* * This file is part of the Lime framework. * * (c) Fabien Potencier <*****@*****.**> * (c) Bernhard Schussek <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ require_once dirname(__FILE__) . '/setup.php'; LimeAnnotationSupport::enable(); $t = new LimeTest(); // @Test $foobar = new NonExistingClass();
/** * Returns the file path of the executed test script * * @return string The file path */ protected static function getScriptPath() { if (is_null(self::$scriptPath)) { $traces = debug_backtrace(); self::$scriptPath = $traces[count($traces) - 1]['file']; } if (!is_file(self::$scriptPath)) { throw new RuntimeException('The script path is not valid: ' . self::$scriptPath); } return self::$scriptPath; }
protected function includeTest($__lime_path) { LimeAnnotationSupport::setScriptPath($__lime_path); $lexer = new LimeLexerVariables(array('Test', 'Before', 'After', 'BeforeAll', 'AfterAll'), array('Before')); // make global variables _really_ global (in case someone uses "global" statements) foreach ($lexer->parse(file_get_contents($__lime_path)) as $__lime_variable) { $__lime_variable = substr($__lime_variable, 1); // strip '$' global ${$__lime_variable}; } return include $__lime_path; }