Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing test cases

  • Loading branch information...
commit e5f2f6a2366587168423336a80b71cd23dfbbb98 1 parent 80b70c1
@ADmad ADmad authored
View
5 lib/Cake/Test/Case/Core/ObjectTest.php
@@ -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');
@@ -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');
View
8 lib/Cake/Test/Case/Log/CakeLogTest.php
@@ -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'));
@@ -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'));
View
16 lib/Cake/Test/Case/Log/Engine/FileLog.php
@@ -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'));
@@ -41,7 +43,9 @@ 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'));
@@ -49,7 +53,9 @@ function testLogFileWriting() {
$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'));
@@ -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');
View
4 lib/Cake/Test/Case/Model/CakeSchemaTest.php
@@ -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();
}
View
3  lib/Cake/Test/Case/Utility/FolderTest.php
@@ -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);
}
View
1  lib/Cake/Test/Case/View/HelperTest.php
@@ -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');
View
4 lib/Cake/Test/Case/View/ViewTest.php
@@ -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+');
Please sign in to comment.
Something went wrong with that request. Please try again.