mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'master' into 2.3
This commit is contained in:
commit
d5333a2ff1
7 changed files with 49 additions and 19 deletions
|
@ -66,22 +66,21 @@ class PhpReader implements ConfigReaderInterface {
|
||||||
$key = substr($key, 0, -4);
|
$key = substr($key, 0, -4);
|
||||||
}
|
}
|
||||||
list($plugin, $key) = pluginSplit($key);
|
list($plugin, $key) = pluginSplit($key);
|
||||||
|
$key .= '.php';
|
||||||
|
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
$file = App::pluginPath($plugin) . 'Config' . DS . $key;
|
$file = App::pluginPath($plugin) . 'Config' . DS . $key;
|
||||||
} else {
|
} else {
|
||||||
$file = $this->_path . $key;
|
$file = $this->_path . $key;
|
||||||
}
|
}
|
||||||
$file .= '.php';
|
|
||||||
if (!is_file($file)) {
|
if (!is_file($file)) {
|
||||||
if (!is_file(substr($file, 0, -4))) {
|
throw new ConfigureException(__d('cake_dev', 'Could not load configuration file: %s', $file));
|
||||||
throw new ConfigureException(__d('cake_dev', 'Could not load configuration files: %s or %s', $file, substr($file, 0, -4)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
include $file;
|
include $file;
|
||||||
if (!isset($config)) {
|
if (!isset($config)) {
|
||||||
throw new ConfigureException(
|
throw new ConfigureException(
|
||||||
sprintf(__d('cake_dev', 'No variable $config found in %s.php'), $file)
|
sprintf(__d('cake_dev', 'No variable $config found in %s'), $file)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $config;
|
return $config;
|
||||||
|
|
|
@ -197,9 +197,10 @@ class DataSource extends Object {
|
||||||
*
|
*
|
||||||
* @param Model $model The model being read.
|
* @param Model $model The model being read.
|
||||||
* @param array $queryData An array of query data used to find the data you want
|
* @param array $queryData An array of query data used to find the data you want
|
||||||
|
* @param integer $recursive Number of levels of association
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function read(Model $model, $queryData = array()) {
|
public function read(Model $model, $queryData = array(), $recursive = null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,9 +212,10 @@ class DataSource extends Object {
|
||||||
* @param Model $model Instance of the model class being updated
|
* @param Model $model Instance of the model class being updated
|
||||||
* @param array $fields Array of fields to be updated
|
* @param array $fields Array of fields to be updated
|
||||||
* @param array $values Array of values to be update $fields to.
|
* @param array $values Array of values to be update $fields to.
|
||||||
|
* @param mixed $conditions
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function update(Model $model, $fields = null, $values = null) {
|
public function update(Model $model, $fields = null, $values = null, $conditions = null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,10 +133,10 @@ class CakeResponse {
|
||||||
'otf' => 'font/otf',
|
'otf' => 'font/otf',
|
||||||
'pdf' => 'application/pdf',
|
'pdf' => 'application/pdf',
|
||||||
'pgn' => 'application/x-chess-pgn',
|
'pgn' => 'application/x-chess-pgn',
|
||||||
'pot' => 'application/mspowerpoint',
|
'pot' => 'application/vnd.ms-powerpoint',
|
||||||
'pps' => 'application/mspowerpoint',
|
'pps' => 'application/vnd.ms-powerpoint',
|
||||||
'ppt' => 'application/mspowerpoint',
|
'ppt' => 'application/vnd.ms-powerpoint',
|
||||||
'ppz' => 'application/mspowerpoint',
|
'ppz' => 'application/vnd.ms-powerpoint',
|
||||||
'pre' => 'application/x-freelance',
|
'pre' => 'application/x-freelance',
|
||||||
'prt' => 'application/pro_eng',
|
'prt' => 'application/pro_eng',
|
||||||
'ps' => 'application/postscript',
|
'ps' => 'application/postscript',
|
||||||
|
|
|
@ -41,7 +41,7 @@ class PhpReaderTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setup
|
* Setup.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +51,7 @@ class PhpReaderTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test reading files
|
* Test reading files.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -65,21 +65,32 @@ class PhpReaderTest extends CakeTestCase {
|
||||||
$this->assertEquals('value', $values['Read']);
|
$this->assertEquals('value', $values['Read']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test an exception is thrown by reading files that exist without .php extension.
|
||||||
|
*
|
||||||
|
* @expectedException ConfigureException
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testReadWithExistentFileWithoutExtension() {
|
||||||
|
$reader = new PhpReader($this->path);
|
||||||
|
$reader->read('no_php_extension');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test an exception is thrown by reading files that don't exist.
|
* Test an exception is thrown by reading files that don't exist.
|
||||||
*
|
*
|
||||||
* @expectedException ConfigureException
|
* @expectedException ConfigureException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadWithNonExistantFile() {
|
public function testReadWithNonExistentFile() {
|
||||||
$reader = new PhpReader($this->path);
|
$reader = new PhpReader($this->path);
|
||||||
$reader->read('fake_values');
|
$reader->read('fake_values');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test reading an empty file.
|
* Test reading an empty file.
|
||||||
*
|
*
|
||||||
* @expectedException RuntimeException
|
* @expectedException ConfigureException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadEmptyFile() {
|
public function testReadEmptyFile() {
|
||||||
|
@ -88,7 +99,7 @@ class PhpReaderTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test reading keys with ../ doesn't work
|
* Test reading keys with ../ doesn't work.
|
||||||
*
|
*
|
||||||
* @expectedException ConfigureException
|
* @expectedException ConfigureException
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -99,7 +110,7 @@ class PhpReaderTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test reading from plugins
|
* Test reading from plugins.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -918,6 +918,13 @@ class CakeRequestTest extends CakeTestCase {
|
||||||
|
|
||||||
$_SERVER['TEST_VAR'] = 'foo';
|
$_SERVER['TEST_VAR'] = 'foo';
|
||||||
$this->assertTrue($request->is('compareCamelCase'), 'Value match failed.');
|
$this->assertTrue($request->is('compareCamelCase'), 'Value match failed.');
|
||||||
|
$this->assertTrue($request->is('comparecamelcase'), 'detectors should be case insensitive');
|
||||||
|
$this->assertTrue($request->is('COMPARECAMELCASE'), 'detectors should be case insensitive');
|
||||||
|
|
||||||
|
$_SERVER['TEST_VAR'] = 'not foo';
|
||||||
|
$this->assertFalse($request->is('compareCamelCase'), 'Value match failed.');
|
||||||
|
$this->assertFalse($request->is('comparecamelcase'), 'detectors should be case insensitive');
|
||||||
|
$this->assertFalse($request->is('COMPARECAMELCASE'), 'detectors should be case insensitive');
|
||||||
|
|
||||||
$request->addDetector('banana', array('env' => 'TEST_VAR', 'pattern' => '/^ban.*$/'));
|
$request->addDetector('banana', array('env' => 'TEST_VAR', 'pattern' => '/^ban.*$/'));
|
||||||
$_SERVER['TEST_VAR'] = 'banana';
|
$_SERVER['TEST_VAR'] = 'banana';
|
||||||
|
|
9
lib/Cake/Test/test_app/Config/no_php_extension
Normal file
9
lib/Cake/Test/test_app/Config/no_php_extension
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
// Test file for testing config file without .php extension.
|
||||||
|
$config = array(
|
||||||
|
'Deep' => array(
|
||||||
|
'Third' => array(
|
||||||
|
'ThirdDeepest' => 'buried3'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
|
@ -181,12 +181,14 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @param string $name The name of the function
|
* @param string $name The name of the function
|
||||||
* @param array $arguments Array of arguments
|
* @param array $arguments Array of arguments
|
||||||
* @return Function
|
* @return the return of _testAction
|
||||||
|
* @throws BadMethodCallException when you call methods that don't exist.
|
||||||
*/
|
*/
|
||||||
public function __call($name, $arguments) {
|
public function __call($name, $arguments) {
|
||||||
if ($name == 'testAction') {
|
if ($name == 'testAction') {
|
||||||
return call_user_func_array(array($this, '_testAction'), $arguments);
|
return call_user_func_array(array($this, '_testAction'), $arguments);
|
||||||
}
|
}
|
||||||
|
throw new BadMethodCallException("Method '{$name}' does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue