示例#1
0
$t->ok($input->done(), 'The input is done');
// @Test: Additional lines and comments are ignored
// fixtures
$output->setExpectNothing();
$output->replay();
// test
$input->parse("Some foobar text\n");
$input->parse("# Some comment\n");
// assertions
$t->ok($input->done(), 'The input is done');
// @Test: A PHP error is passed to error() - invalid identifier
// @Test: Case 1 - Invalid identifier
// fixtures
$output->error(new LimeError("syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '\$'", $file, 1, 'Parse error'));
$output->replay();
file_put_contents($file, '<?php $1invalidname;');
$command = new LimeCommand($executable, $file);
$command->execute();
// test
$input->parse($command->getOutput());
// @Test: Case 2 - Failed require
// fixtures
$output->error(new LimeError("require(foobar.php): failed to open stream: No such file or directory", $file, 1, 'Warning'));
$output->error(new LimeError("require(): Failed opening required 'foobar.php' (include_path='" . get_include_path() . "')", $file, 1, 'Fatal error'));
$output->replay();
file_put_contents($file, '<?php require "foobar.php";');
$command = new LimeCommand($executable, $file);
$command->execute();
// test
$input->parse($command->getOutput());
示例#2
0
/*
 * 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.
 */
LimeAnnotationSupport::enable();
$t = new LimeTest();
// @Before
$executable = new LimeExecutable(LimeExecutable::php() . ' %file%');
// @Test: A PHP file can be executed
// fixtures
$file = tempnam(sys_get_temp_dir(), 'lime');
file_put_contents($file, <<<EOF
<?php
echo "Test";
file_put_contents("php://stderr", "Errors");
exit(1);
EOF
);
// test
$command = new LimeCommand($executable, $file);
$command->execute();
// assertions
$t->is($command->getOutput(), 'Test', 'The output is correct');
$t->is($command->getErrors(), 'Errors', 'The errors are correct');
$t->is($command->getStatus(), 1, 'The return value is correct');