Skip to content

Instantly share code, notes, and snippets.

@ChrisJStone
Created July 27, 2011 16:07
Show Gist options
  • Save ChrisJStone/1109703 to your computer and use it in GitHub Desktop.
Save ChrisJStone/1109703 to your computer and use it in GitHub Desktop.
assertTrue fails to output message
<?php
require_once(dirname(__FILE__) . '/simpletest/autorun.php');
require_once('../classes/log.php');
class TestOfLogging extends UnitTestCase {
function __construct() {
parent::__construct('Log test');
}
function testCreatingNewFile() {
unlink(dirname(__FILE__) . '/../temp/test.log');
$log = new Log(dirname(__FILE__) . '/../temp/test.log');
$this->assertFalse(file_exists(dirname(__FILE__) . '/../temp/test.log'), 'Created before message');
$log->message('Should write this to a file');
$this->assertTrue(file_exists(dirname(__FILE__) . '/../temp/test.log'), 'File created');
}
}
?>
Commenting out unlink .... in log_test.php causes assertFalse to output message as expected
log_test.php
1) Created before message at [/var/www/html/tutorial/tests/log_test.php line 13]
in testCreatingNewFile
in Log test
FAILURES!!!
Test cases run: 1/1, Passes: 1, Failures: 1, Exceptions: 0
$this->assertTrue(file_exists(dirname(__FILE__) . '/../temp/test.log'), 'File created'); does not output File created
log_test.php
OK
Test cases run: 1/1, Passes: 2, Failures: 0, Exceptions: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment