Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed test cases for successful being built on travis.

  • Loading branch information...
commit fda065101ba3414fcc82eecc521295fa9ac41e6a 1 parent d748fc7
@tPl0ch tPl0ch authored
View
1  .travis.yml
@@ -1,6 +1,7 @@
language: php
php:
+ - 5.2
- 5.3
- 5.4
View
7 lib/Cake/Cache/Cache.php
@@ -250,11 +250,12 @@ public static function set($settings = array(), $value = null, $config = 'defaul
*
* Permanently remove all expired and deleted data
*
- * @param string $config The config name you wish to have garbage collected. Defaults to 'default'
+ * @param string $config [optional] The config name you wish to have garbage collected. Defaults to 'default'
+ * @param integer $expires [optional] An expires timestamp. Defaults to NULL
* @return void
*/
- public static function gc($config = 'default') {
- self::$_engines[$config]->gc();
+ public static function gc($config = 'default', $expires = null) {
+ self::$_engines[$config]->gc($expires);
}
/**
View
4 lib/Cake/Cache/CacheEngine.php
@@ -51,9 +51,11 @@ public function init($settings = array()) {
* Garbage collection
*
* Permanently remove all expired and deleted data
+ *
+ * @param integer $expires [optional] An expires timestamp, invalidataing all data before.
* @return void
*/
- public function gc() {
+ public function gc($expires = null) {
}
/**
View
5 lib/Cake/Cache/Engine/FileEngine.php
@@ -87,10 +87,11 @@ public function init($settings = array()) {
/**
* Garbage collection. Permanently remove all expired and deleted data
- *
+ *
+ * @param integer $expires [optional] An expires timestamp, invalidataing all data before.
* @return boolean True if garbage collection was successful, false on failure
*/
- public function gc() {
+ public function gc($expires = null) {
return $this->clear(true);
}
View
4 lib/Cake/Model/Datasource/CakeSession.php
@@ -180,7 +180,7 @@ public static function start() {
if (self::started()) {
return true;
}
- CakeSession::init();
+ self::init();
$id = self::id();
session_write_close();
self::_configureSession();
@@ -601,8 +601,6 @@ protected static function _startSession() {
if (empty($_SESSION)) {
$_SESSION = array();
}
- } elseif (!isset($_SESSION)) {
- session_start();
} else {
session_start();
}
View
21 lib/Cake/Model/Datasource/Session/CacheSession.php
@@ -43,10 +43,6 @@ public function open() {
* @return boolean Success
*/
public function close() {
- $probability = mt_rand(1, 150);
- if ($probability <= 3) {
- Cache::gc();
- }
return true;
}
@@ -74,7 +70,7 @@ public function write($id, $data) {
/**
* Method called on the destruction of a database session.
*
- * @param integer $id ID that uniquely identifies session in database
+ * @param integer $id ID that uniquely identifies session in cache
* @return boolean True for successful delete, false otherwise.
*/
public function destroy($id) {
@@ -82,13 +78,22 @@ public function destroy($id) {
}
/**
- * Helper function called on gc for database sessions.
+ * Helper function called on gc for cache sessions.
*
* @param integer $expires Timestamp (defaults to current time)
* @return boolean Success
*/
public function gc($expires = null) {
- return Cache::gc();
+ return Cache::gc(Configure::read('Session.handler.config'), $expires);
+ }
+
+/**
+ * Writes and closes a session
+ *
+ * @return void
+ */
+ protected function _writeSession() {
+ session_write_close();
}
/**
@@ -97,7 +102,7 @@ public function gc($expires = null) {
* @return void
*/
public function __destruct() {
- session_write_close();
+ $this->_writeSession();
}
}
View
18 lib/Cake/Model/Datasource/Session/DatabaseSession.php
@@ -79,10 +79,6 @@ public function open() {
* @return boolean Success
*/
public function close() {
- $probability = mt_rand(1, 150);
- if ($probability <= 3) {
- $this->gc();
- }
return true;
}
@@ -145,15 +141,21 @@ public function gc($expires = null) {
}
/**
+ * Writes and closes a session
+ *
+ * @return void
+ */
+ protected function _writeSession() {
+ session_write_close();
+ }
+
+/**
* Closes the session before the objects handling it become unavailable
*
* @return void
*/
public function __destruct() {
- try {
- session_write_close();
- } catch (Exception $e) {
- }
+ $this->_writeSession();
}
}
View
26 lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php
@@ -18,6 +18,8 @@
*/
App::uses('CakeSession', 'Model/Datasource');
+App::uses('DatabaseSession', 'Model/Datasource/Session');
+App::uses('CacheSession', 'Model/Datasource/Session');
class TestCakeSession extends CakeSession {
@@ -31,6 +33,20 @@ public static function setHost($host) {
}
+class TestCacheSession extends CacheSession {
+
+ protected function _writeSession() {
+ return true;
+ }
+}
+
+class TestDatabaseSession extends DatabaseSession {
+
+ protected function _writeSession() {
+ return true;
+ }
+}
+
/**
* CakeSessionTest class
*
@@ -92,7 +108,7 @@ public function setUp() {
*/
public function teardown() {
if (TestCakeSession::started()) {
- TestCakeSession::clear();
+ session_write_close();
}
unset($_SESSION);
parent::teardown();
@@ -550,6 +566,7 @@ public function testUsingPluginHandler() {
*/
public function testReadAndWriteWithCacheStorage() {
Configure::write('Session.defaults', 'cache');
+ Configure::write('Session.handler.engine', 'TestCacheSession');
TestCakeSession::init();
TestCakeSession::destroy();
@@ -585,6 +602,7 @@ public function testReadAndWriteWithCacheStorage() {
*/
public function testReadAndWriteWithCustomCacheConfig() {
Configure::write('Session.defaults', 'cache');
+ Configure::write('Session.handler.engine', 'TestCacheSession');
Configure::write('Session.handler.config', 'session_test');
Cache::config('session_test', array(
@@ -609,6 +627,7 @@ public function testReadAndWriteWithCustomCacheConfig() {
*/
public function testReadAndWriteWithDatabaseStorage() {
Configure::write('Session.defaults', 'database');
+ Configure::write('Session.handler.engine', 'TestDatabaseSession');
Configure::write('Session.handler.table', 'sessions');
Configure::write('Session.handler.model', 'Session');
Configure::write('Session.handler.database', 'test');
@@ -651,6 +670,7 @@ public function testReadAndWriteWithDatabaseStorage() {
*/
public function testSessionTimeout() {
Configure::write('debug', 2);
+ Configure::write('Session.defaults', 'cake');
Configure::write('Session.autoRegenerate', false);
$timeoutSeconds = Configure::read('Session.timeout') * 60;
@@ -683,7 +703,7 @@ public function testSessionTimeout() {
public function testCookieTimeoutFallback() {
$_SESSION = null;
Configure::write('Session', array(
- 'defaults' => 'php',
+ 'defaults' => 'cake',
'timeout' => 400,
));
TestCakeSession::start();
@@ -692,7 +712,7 @@ public function testCookieTimeoutFallback() {
$_SESSION = null;
Configure::write('Session', array(
- 'defaults' => 'php',
+ 'defaults' => 'cake',
'timeout' => 400,
'cookieTimeout' => 600
));
View
2  lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
@@ -353,7 +353,7 @@ public function testDescribeWithUuidPrimaryKey() {
public function testVirtualFieldWithFunction() {
$this->loadFixtures('User');
$User = ClassRegistry::init('User');
- $User->virtualFields = array('name' => 'SUBSTR(User.user, 5)');
+ $User->virtualFields = array('name' => 'SUBSTR(User.user, 5, LENGTH(User.user) - 4)');
$result = $User->find('first', array(
'conditions' => array('User.user' => 'garrett')
View
9 lib/Cake/Test/Case/Utility/FileTest.php
@@ -80,7 +80,8 @@ public function testBasic() {
'filesize' => filesize($file),
'mime' => 'text/x-php'
);
- if (!function_exists('finfo_open') && !function_exists('mime_content_type')) {
+ if (!function_exists('finfo_open') && (!function_exists('mime_content_type') ||
+ function_exists('mime_content_type') && false === mime_content_type($this->File->pwd()))) {
$expecting['mime'] = false;
}
@@ -480,7 +481,11 @@ public function testMime() {
$this->skipIf(!function_exists('finfo_open') && !function_exists('mime_content_type'), 'Not able to read mime type');
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif';
$file = new File($path);
- $this->assertEquals('image/gif', $file->mime());
+ $expected = 'image/gif';
+ if (function_exists('mime_content_type') && false === mime_content_type($file->pwd())) {
+ $expected = false;
+ }
+ $this->assertEquals($expected, $file->mime());
}
/**
View
15 lib/Cake/Test/Case/View/Helper/RssHelperTest.php
@@ -607,7 +607,12 @@ public function testItemEnclosureLength() {
$File = new File($tmpFile, true);
$this->assertTrue($File->write('123'), 'Could not write to ' . $tmpFile);
- clearstatcache(true, $tmpFile);
+
+ if (50300 <= PHP_VERSION_ID) {
+ clearstatcache(true, $tmpFile);
+ } else {
+ clearstatcache();
+ }
$item = array(
'title' => array(
@@ -637,6 +642,12 @@ public function testItemEnclosureLength() {
)
);
$result = $this->Rss->item(null, $item);
+ if (!function_exists('finfo_open') &&
+ (function_exists('mime_content_type') && false === mime_content_type($tmpFile))) {
+ $type = false;
+ } else {
+ $type = 'text/plain';
+ }
$expected = array(
'<item',
'<title',
@@ -651,7 +662,7 @@ public function testItemEnclosureLength() {
'enclosure' => array(
'url' => $this->Rss->url('/tests/cakephp.file.test.tmp', true),
'length' => filesize($tmpFile),
- 'type' => 'text/plain'
+ 'type' => $type
),
'<pubDate',
date('r', strtotime('2008-05-31 12:00:00')),
Please sign in to comment.
Something went wrong with that request. Please try again.