mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing test cases
This commit is contained in:
parent
80b70c100e
commit
e5f2f6a236
7 changed files with 30 additions and 11 deletions
|
@ -368,7 +368,9 @@ class ObjectTest extends CakeTestCase {
|
|||
* @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 @@ class ObjectTest extends CakeTestCase {
|
|||
$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');
|
||||
|
|
|
@ -95,7 +95,9 @@ class CakeLogTest extends CakeTestCase {
|
|||
* @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 @@ class CakeLogTest extends CakeTestCase {
|
|||
* @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'));
|
||||
|
|
|
@ -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 @@ class FileLogTest extends CakeTestCase {
|
|||
$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 @@ class FileLogTest extends CakeTestCase {
|
|||
$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 @@ class FileLogTest extends CakeTestCase {
|
|||
*/
|
||||
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');
|
||||
|
|
|
@ -526,7 +526,9 @@ class CakeSchemaTest extends CakeTestCase {
|
|||
*/
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -300,8 +300,9 @@ class FolderTest extends CakeTestCase {
|
|||
$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);
|
||||
}
|
||||
|
|
|
@ -526,6 +526,7 @@ class HelperTest extends CakeTestCase {
|
|||
$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');
|
||||
|
||||
|
|
|
@ -790,7 +790,9 @@ class ViewTest extends CakeTestCase {
|
|||
|
||||
$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+');
|
||||
|
|
Loading…
Reference in a new issue