Skip to content

Commit

Permalink
Fixing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed May 28, 2011
1 parent 80b70c1 commit e5f2f6a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
5 changes: 3 additions & 2 deletions lib/Cake/Test/Case/Core/ObjectTest.php
Expand Up @@ -368,7 +368,9 @@ function tearDown() {
* @return void
*/
function testLog() {
@unlink(LOGS . 'error.log');
if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log');
}
$this->assertTrue($this->object->log('Test warning 1'));
$this->assertTrue($this->object->log(array('Test' => 'warning 2')));
$result = file(LOGS . 'error.log');
Expand All @@ -379,7 +381,6 @@ function testLog() {
$this->assertPattern('/^\)$/', $result[4]);
unlink(LOGS . 'error.log');

@unlink(LOGS . 'error.log');
$this->assertTrue($this->object->log('Test warning 1', LOG_WARNING));
$this->assertTrue($this->object->log(array('Test' => 'warning 2'), LOG_WARNING));
$result = file(LOGS . 'error.log');
Expand Down
8 changes: 6 additions & 2 deletions lib/Cake/Test/Case/Log/CakeLogTest.php
Expand Up @@ -95,7 +95,9 @@ function testNotImplementingInterface() {
* @return void
*/
function testAutoConfig() {
@unlink(LOGS . 'error.log');
if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log');
}
CakeLog::write(LOG_WARNING, 'Test warning');
$this->assertTrue(file_exists(LOGS . 'error.log'));

Expand Down Expand Up @@ -153,7 +155,9 @@ function testDrop() {
* @return void
*/
function testLogFileWriting() {
@unlink(LOGS . 'error.log');
if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log');
}
$result = CakeLog::write(LOG_WARNING, 'Test warning');
$this->assertTrue($result);
$this->assertTrue(file_exists(LOGS . 'error.log'));
Expand Down
16 changes: 12 additions & 4 deletions lib/Cake/Test/Case/Log/Engine/FileLog.php
Expand Up @@ -32,7 +32,9 @@ class FileLogTest extends CakeTestCase {
* @return void
*/
function testLogFileWriting() {
@unlink(LOGS . 'error.log');
if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log');
}
$log = new FileLog();
$log->write('warning', 'Test warning');
$this->assertTrue(file_exists(LOGS . 'error.log'));
Expand All @@ -41,15 +43,19 @@ function testLogFileWriting() {
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning/', $result);
unlink(LOGS . 'error.log');

@unlink(LOGS . 'debug.log');
if (file_exists(LOGS . 'debug.log')) {
unlink(LOGS . 'debug.log');
}
$log->write('debug', 'Test warning');
$this->assertTrue(file_exists(LOGS . 'debug.log'));

$result = file_get_contents(LOGS . 'debug.log');
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Debug: Test warning/', $result);
unlink(LOGS . 'debug.log');

@unlink(LOGS . 'random.log');
if (file_exists(LOGS . 'random.log')) {
unlink(LOGS . 'random.log');
}
$log->write('random', 'Test warning');
$this->assertTrue(file_exists(LOGS . 'random.log'));

Expand All @@ -65,7 +71,9 @@ function testLogFileWriting() {
*/
function testPathSetting() {
$path = TMP . 'tests' . DS;
@unlink($path . 'error.log');
if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log');
}

$log = new FileLog(compact('path'));
$log->write('warning', 'Test warning');
Expand Down
4 changes: 3 additions & 1 deletion lib/Cake/Test/Case/Model/CakeSchemaTest.php
Expand Up @@ -526,7 +526,9 @@ function setUp() {
*/
function tearDown() {
parent::tearDown();
@unlink(TMP . 'tests' . DS .'schema.php');
if (file_exists(TMP . 'tests' . DS .'schema.php')) {
unlink(TMP . 'tests' . DS .'schema.php');
}
unset($this->Schema);
CakePlugin::unload();
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Test/Case/Utility/FolderTest.php
Expand Up @@ -300,8 +300,9 @@ function testFolderRead() {
$result = $Folder->read(true, true);
$this->assertEqual($result[0], $expected);

$Folder->path = TMP . DS . 'non-existent';
$Folder->path = TMP . 'non-existent';
$expected = array(array(), array());
$this->setExpectedException('PHPUnit_Framework_Error_Warning');
$result = $Folder->read(true, true);
$this->assertEqual($expected, $result);
}
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/View/HelperTest.php
Expand Up @@ -526,6 +526,7 @@ function testAssetTimestampPluginsAndThemes() {
$result = $this->Helper->assetTimestamp('/test_plugin/css/test_plugin_asset.css');
$this->assertPattern('#/test_plugin/css/test_plugin_asset.css\?[0-9]+$#', $result, 'Missing timestamp plugin');

$this->setExpectedException('PHPUnit_Framework_Error_Warning');
$result = $this->Helper->assetTimestamp('/test_plugin/css/i_dont_exist.css');
$this->assertPattern('#/test_plugin/css/i_dont_exist.css\?$#', $result, 'No error on missing file');

Expand Down
4 changes: 3 additions & 1 deletion lib/Cake/Test/Case/View/ViewTest.php
Expand Up @@ -790,7 +790,9 @@ function testRenderCache() {

$result = $View->renderCache($path, '+1 second');
$this->assertFalse($result);
@unlink($path);
if (file_exists($path)) {
unlink($path);
}

$cacheText = '<!--cachetime:' . (time() + 10) . '-->some cacheText';
$f = fopen($path, 'w+');
Expand Down

0 comments on commit e5f2f6a

Please sign in to comment.