mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '2.0' of github.com:cakephp/cakephp into 2.0
This commit is contained in:
commit
95acaba295
8 changed files with 87 additions and 38 deletions
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
App::uses('DboSource', 'Model/Datasource');
|
||||
App::uses('String', 'Utility');
|
||||
|
||||
/**
|
||||
* DBO implementation for the SQLite3 DBMS.
|
||||
|
@ -281,7 +282,7 @@ class Sqlite extends DboSource {
|
|||
$last = strripos($querystring, 'FROM');
|
||||
if ($last !== false) {
|
||||
$selectpart = substr($querystring, 7, $last - 8);
|
||||
$selects = explode(',', $selectpart);
|
||||
$selects = String::tokenize($selectpart, ',', '(', ')');
|
||||
}
|
||||
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
|
||||
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');
|
||||
|
|
|
@ -20,6 +20,8 @@ App::uses('Model', 'Model');
|
|||
App::uses('AppModel', 'Model');
|
||||
App::uses('Sqlite', 'Model/Datasource/Database');
|
||||
|
||||
require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
|
||||
|
||||
/**
|
||||
* DboSqliteTestDb class
|
||||
*
|
||||
|
@ -88,6 +90,7 @@ class SqliteTest extends CakeTestCase {
|
|||
*
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
Configure::write('Cache.disable', true);
|
||||
$this->Dbo = ConnectionManager::getDataSource('test');
|
||||
if (!$this->Dbo instanceof Sqlite) {
|
||||
|
@ -100,6 +103,7 @@ class SqliteTest extends CakeTestCase {
|
|||
*
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
Configure::write('Cache.disable', false);
|
||||
}
|
||||
|
||||
|
@ -318,4 +322,20 @@ class SqliteTest extends CakeTestCase {
|
|||
$this->assertEqual($result['id'], $expected);
|
||||
$this->Dbo->query('DROP TABLE ' . $tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test virtualFields with functions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testVirtualFieldWithFunction() {
|
||||
$this->loadFixtures('User');
|
||||
$User = ClassRegistry::init('User');
|
||||
$User->virtualFields = array('name' => 'SUBSTR(User.user, 5)');
|
||||
|
||||
$result = $User->find('first', array(
|
||||
'conditions' => array('User.user' => 'garrett')
|
||||
));
|
||||
$this->assertEquals('ett', $result['User']['name']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -403,7 +403,7 @@ class DebuggerTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function testNoDbCredentials() {
|
||||
public function testNoDbCredentials() {
|
||||
$config = array(
|
||||
'driver' => 'mysql',
|
||||
'persistent' => false,
|
||||
|
@ -429,4 +429,19 @@ class DebuggerTest extends CakeTestCase {
|
|||
|
||||
$this->assertEqual($expected, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* test trace exclude
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTraceExclude() {
|
||||
$result = Debugger::trace();
|
||||
$this->assertPattern('/^DebuggerTest::testTraceExclude/', $result);
|
||||
|
||||
$result = Debugger::trace(array(
|
||||
'exclude' => array('DebuggerTest::testTraceExclude')
|
||||
));
|
||||
$this->assertNoPattern('/^DebuggerTest::testTraceExclude/', $result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ class HelperTest extends CakeTestCase {
|
|||
*/
|
||||
public function testSetEntityScoped() {
|
||||
$this->Helper->setEntity('HelperTestPost', true);
|
||||
$this->assertEquals(array('HelperTestPost'), $this->Helper->entity());
|
||||
$this->assertEquals(array('HelperTestPost'), $this->Helper->entity());
|
||||
|
||||
$this->Helper->setEntity('id');
|
||||
$expected = array('HelperTestPost', 'id');
|
||||
|
@ -310,6 +310,19 @@ class HelperTest extends CakeTestCase {
|
|||
$this->assertEquals('HelperTestComment', $this->Helper->model());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creating saveMany() compatible entities
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSetEntitySaveMany() {
|
||||
$this->Helper->setEntity('HelperTestPost', true);
|
||||
|
||||
$this->Helper->setEntity('0.HelperTestPost.id');
|
||||
$expected = array('0', 'HelperTestPost', 'id');
|
||||
$this->assertEquals($expected, $this->Helper->entity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that setEntity doesn't make CamelCase fields that are not associations an
|
||||
* associated model.
|
||||
|
|
|
@ -387,8 +387,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertEqual($result, $expected, $message = '') {
|
||||
return $this->assertEquals($expected, $result, $message);
|
||||
protected static function assertEqual($result, $expected, $message = '') {
|
||||
return self::assertEquals($expected, $result, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -399,8 +399,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertNotEqual($result, $expected, $message = '') {
|
||||
return $this->assertNotEquals($expected, $result, $message);
|
||||
protected static function assertNotEqual($result, $expected, $message = '') {
|
||||
return self::assertNotEquals($expected, $result, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -411,8 +411,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertPattern($pattern, $string, $message = '') {
|
||||
return $this->assertRegExp($pattern, $string, $message);
|
||||
protected static function assertPattern($pattern, $string, $message = '') {
|
||||
return self::assertRegExp($pattern, $string, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -423,8 +423,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertIdentical($actual, $expected, $message = '') {
|
||||
return $this->assertSame($expected, $actual, $message);
|
||||
protected static function assertIdentical($actual, $expected, $message = '') {
|
||||
return self::assertSame($expected, $actual, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -435,8 +435,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertNotIdentical($actual, $expected, $message = '') {
|
||||
return $this->assertNotSame($expected, $actual, $message);
|
||||
protected static function assertNotIdentical($actual, $expected, $message = '') {
|
||||
return self::assertNotSame($expected, $actual, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -447,8 +447,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertNoPattern($pattern, $string, $message = '') {
|
||||
return $this->assertNotRegExp($pattern, $string, $message);
|
||||
protected static function assertNoPattern($pattern, $string, $message = '') {
|
||||
return self::assertNotRegExp($pattern, $string, $message);
|
||||
}
|
||||
|
||||
protected function assertNoErrors() {
|
||||
|
@ -487,8 +487,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertReference(&$first, &$second, $message = '') {
|
||||
return $this->assertSame($first, $second, $message);
|
||||
protected static function assertReference(&$first, &$second, $message = '') {
|
||||
return self::assertSame($first, $second, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -499,8 +499,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
protected function assertIsA($object, $type, $message = '') {
|
||||
return $this->assertInstanceOf($type, $object, $message);
|
||||
protected static function assertIsA($object, $type, $message = '') {
|
||||
return self::assertInstanceOf($type, $object, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -512,10 +512,10 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @param string $message the text to display if the assertion is not correct
|
||||
* @return void
|
||||
*/
|
||||
protected function assertWithinMargin($result, $expected, $margin, $message = '') {
|
||||
protected static function assertWithinMargin($result, $expected, $margin, $message = '') {
|
||||
$upper = $result + $margin;
|
||||
$lower = $result - $margin;
|
||||
$this->assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
|
||||
return self::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -285,9 +285,9 @@ class Debugger {
|
|||
'args' => false,
|
||||
'start' => 0,
|
||||
'scope' => null,
|
||||
'exclude' => null
|
||||
'exclude' => array('call_user_func_array', 'trigger_error')
|
||||
);
|
||||
$options += $defaults;
|
||||
$options = Set::merge($defaults, $options);
|
||||
|
||||
$backtrace = debug_backtrace();
|
||||
$count = count($backtrace);
|
||||
|
@ -302,13 +302,15 @@ class Debugger {
|
|||
|
||||
for ($i = $options['start']; $i < $count && $i < $options['depth']; $i++) {
|
||||
$trace = array_merge(array('file' => '[internal]', 'line' => '??'), $backtrace[$i]);
|
||||
$signature = $reference = '[main]';
|
||||
|
||||
if (isset($backtrace[$i + 1])) {
|
||||
$next = array_merge($_trace, $backtrace[$i + 1]);
|
||||
$reference = $next['function'];
|
||||
$signature = $reference = $next['function'];
|
||||
|
||||
if (!empty($next['class'])) {
|
||||
$reference = $next['class'] . '::' . $reference . '(';
|
||||
$signature = $next['class'] . '::' . $next['function'];
|
||||
$reference = $signature . '(';
|
||||
if ($options['args'] && isset($next['args'])) {
|
||||
$args = array();
|
||||
foreach ($next['args'] as $arg) {
|
||||
|
@ -318,10 +320,8 @@ class Debugger {
|
|||
}
|
||||
$reference .= ')';
|
||||
}
|
||||
} else {
|
||||
$reference = '[main]';
|
||||
}
|
||||
if (in_array($reference, array('call_user_func_array', 'trigger_error'))) {
|
||||
if (in_array($signature, $options['exclude'])) {
|
||||
continue;
|
||||
}
|
||||
if ($options['format'] == 'points' && $trace['file'] != '[internal]') {
|
||||
|
|
|
@ -444,9 +444,9 @@ class Helper extends Object {
|
|||
$entity = $this->_modelScope . '.' . $entity;
|
||||
}
|
||||
|
||||
// 0.name, 0.created.month style inputs.
|
||||
// 0.name, 0.created.month style inputs. Excludes inputs with the modelScope in them.
|
||||
if (
|
||||
$count >= 2 && is_numeric($parts[0]) && !is_numeric($parts[1]) && $this->_modelScope
|
||||
$count >= 2 && is_numeric($parts[0]) && !is_numeric($parts[1]) && $this->_modelScope && strpos($entity, $this->_modelScope) === false
|
||||
) {
|
||||
$entity = $this->_modelScope . '.' . $entity;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ class View extends Object {
|
|||
|
||||
/**
|
||||
* Sub-directory for this view file. This is often used for extension based routing.
|
||||
* for example with an `xml` extension, $subDir would be `xml/`
|
||||
* Eg. With an `xml` extension, $subDir would be `xml/`
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -158,7 +158,7 @@ class View extends Object {
|
|||
public $cacheAction = false;
|
||||
|
||||
/**
|
||||
* holds current errors for the model validation
|
||||
* Holds current errors for the model validation.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -172,7 +172,7 @@ class View extends Object {
|
|||
public $hasRendered = false;
|
||||
|
||||
/**
|
||||
* List of generated DOM UUIDs
|
||||
* List of generated DOM UUIDs.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -205,7 +205,7 @@ class View extends Object {
|
|||
public $elementCache = 'default';
|
||||
|
||||
/**
|
||||
* List of variables to collect from the associated controller
|
||||
* List of variables to collect from the associated controller.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -215,7 +215,7 @@ class View extends Object {
|
|||
);
|
||||
|
||||
/**
|
||||
* Scripts (and/or other <head /> tags) for the layout
|
||||
* Scripts (and/or other <head /> tags) for the layout.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -229,7 +229,7 @@ class View extends Object {
|
|||
protected $_paths = array();
|
||||
|
||||
/**
|
||||
* boolean to indicate that helpers have been loaded.
|
||||
* Indicate that helpers have been loaded.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
|
@ -238,7 +238,7 @@ class View extends Object {
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Controller $controller A controller object to pull View::__passedArgs from.
|
||||
* @param Controller $controller A controller object to pull View::_passedVars from.
|
||||
*/
|
||||
public function __construct($controller) {
|
||||
if (is_object($controller)) {
|
||||
|
@ -337,7 +337,7 @@ class View extends Object {
|
|||
* Renders view for given view file and layout.
|
||||
*
|
||||
* Render triggers helper callbacks, which are fired before and after the view are rendered,
|
||||
* as well as before and after the layout. The helper callbacks are called
|
||||
* as well as before and after the layout. The helper callbacks are called:
|
||||
*
|
||||
* - `beforeRender`
|
||||
* - `afterRender`
|
||||
|
|
Loading…
Reference in a new issue