mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '2.7' into 2.8
This commit is contained in:
commit
ca19b63a32
33 changed files with 280 additions and 75 deletions
|
@ -1,5 +1,5 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ app/webroot/ [L]
|
||||
RewriteRule (.*) app/webroot/$1 [L]
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ app/webroot/ [L]
|
||||
RewriteRule (.*) app/webroot/$1 [L]
|
||||
</IfModule>
|
|
@ -63,6 +63,10 @@ Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer)
|
|||
repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.md) contains installation info
|
||||
for the sniff and phpcs.
|
||||
|
||||
## Reporting a Security Issue
|
||||
|
||||
If you've found a security related issue in CakePHP, please don't open an issue in GitHub. Instead contact us at security@cakephp.org. For more information on how we handle security issues, [see the CakePHP Security Issue Process](http://book.cakephp.org/2.0/en/contributing/tickets.html#reporting-security-issues).
|
||||
|
||||
# Additional Resources
|
||||
|
||||
* [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
</IfModule>
|
|
@ -1,6 +1,6 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
|
|
|
@ -44,7 +44,7 @@ class XcacheEngine extends CacheEngine {
|
|||
* @return bool True if the engine has been successfully initialized, false if not
|
||||
*/
|
||||
public function init($settings = array()) {
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
parent::init(array_merge(array(
|
||||
'engine' => 'Xcache',
|
||||
'prefix' => Inflector::slug(APP_DIR) . '_',
|
||||
|
|
|
@ -414,19 +414,26 @@ class FixtureTask extends BakeTask {
|
|||
* @return array Array of records.
|
||||
*/
|
||||
protected function _getRecordsFromTable($modelName, $useTable = null) {
|
||||
$modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
|
||||
if ($this->interactive) {
|
||||
$condition = null;
|
||||
$prompt = __d('cake_console', "Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1");
|
||||
while (!$condition) {
|
||||
$condition = $this->in($prompt, null, 'WHERE 1=1');
|
||||
}
|
||||
|
||||
$recordsFound = $modelObject->find('count', array(
|
||||
'conditions' => $condition,
|
||||
'recursive' => -1,
|
||||
));
|
||||
|
||||
$prompt = __d('cake_console', "How many records do you want to import?");
|
||||
$recordCount = $this->in($prompt, null, 10);
|
||||
$recordCount = $this->in($prompt, null, ($recordsFound < 10 ) ? $recordsFound : 10);
|
||||
} else {
|
||||
$condition = 'WHERE 1=1';
|
||||
$recordCount = (isset($this->params['count']) ? $this->params['count'] : 10);
|
||||
}
|
||||
$modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
|
||||
|
||||
$records = $modelObject->find('all', array(
|
||||
'conditions' => $condition,
|
||||
'recursive' => -1,
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<ul>
|
||||
|
||||
<?php if (strpos($action, 'add') === false): ?>
|
||||
<li><?php echo "<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), array(), __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>"; ?></li>
|
||||
<li><?php echo "<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), array('confirm' => __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}')))); ?>"; ?></li>
|
||||
<?php endif; ?>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>"; ?></li>
|
||||
<?php
|
||||
|
|
|
@ -43,7 +43,7 @@ foreach ($fields as $field) {
|
|||
<ul>
|
||||
<?php
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array(), __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}']))); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?> </li>\n";
|
||||
|
||||
|
@ -117,7 +117,7 @@ echo "\t<?php foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}): ?
|
|||
echo "\t\t\t<td class=\"actions\">\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Html->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), array(), __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}']))); ?>\n";
|
||||
echo "\t\t\t</td>\n";
|
||||
echo "\t\t</tr>\n";
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
</IfModule>
|
|
@ -1,6 +1,6 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
|
|
|
@ -77,7 +77,7 @@ if (!defined('WWW_ROOT')) {
|
|||
}
|
||||
|
||||
// for built-in server
|
||||
if (php_sapi_name() === 'cli-server') {
|
||||
if (PHP_SAPI === 'cli-server') {
|
||||
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -309,7 +309,8 @@ class EmailComponent extends Component {
|
|||
$lib->readReceipt($this->_formatAddresses((array)$this->readReceipt));
|
||||
}
|
||||
|
||||
$lib->subject($this->subject)->messageID($this->messageId);
|
||||
$lib->subject($this->subject);
|
||||
$lib->messageID($this->messageId);
|
||||
$lib->helpers($this->_controller->helpers);
|
||||
|
||||
$headers = array('X-Mailer' => $this->xMailer);
|
||||
|
|
|
@ -514,12 +514,12 @@ class Controller extends Object implements CakeEventListener {
|
|||
!$method->isPublic() ||
|
||||
!in_array($method->name, $this->methods)
|
||||
);
|
||||
$prefixes = Router::prefixes();
|
||||
$prefixes = array_map('strtolower', Router::prefixes());
|
||||
|
||||
if (!$privateAction && !empty($prefixes)) {
|
||||
if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) {
|
||||
list($prefix) = explode('_', $request->params['action']);
|
||||
$privateAction = in_array($prefix, $prefixes);
|
||||
$privateAction = in_array(strtolower($prefix), $prefixes);
|
||||
}
|
||||
}
|
||||
return $privateAction;
|
||||
|
|
|
@ -156,7 +156,7 @@ class ErrorHandler {
|
|||
$message .= "\nException Attributes: " . var_export($exception->getAttributes(), true);
|
||||
}
|
||||
}
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
$request = Router::getRequest();
|
||||
if ($request) {
|
||||
$message .= "\nRequest URL: " . $request->here();
|
||||
|
|
|
@ -497,6 +497,9 @@ class I18n {
|
|||
$msgid = substr($data, $r["offs"], $r["len"]);
|
||||
unset($msgid_plural);
|
||||
|
||||
if (strpos($msgid, "\x04") !== false) {
|
||||
list($context, $msgid) = explode("\x04", $msgid);
|
||||
}
|
||||
if (strpos($msgid, "\000")) {
|
||||
list($msgid, $msgid_plural) = explode("\000", $msgid);
|
||||
}
|
||||
|
@ -508,9 +511,10 @@ class I18n {
|
|||
}
|
||||
|
||||
if ($msgid != '') {
|
||||
$msgstr = array($context => $msgstr);
|
||||
$translations[$msgid][$context] = $msgstr;
|
||||
} else {
|
||||
$translations[$msgid] = $msgstr;
|
||||
}
|
||||
$translations[$msgid] = $msgstr;
|
||||
|
||||
if (isset($msgid_plural)) {
|
||||
$translations[$msgid_plural] =& $translations[$msgid];
|
||||
|
|
|
@ -857,6 +857,12 @@ class DboSource extends DataSource {
|
|||
* @return bool True if the database is connected, else false
|
||||
*/
|
||||
public function isConnected() {
|
||||
try {
|
||||
$connected = $this->_connection->query('SELECT 1');
|
||||
} catch (Exception $e) {
|
||||
$connected = false;
|
||||
}
|
||||
$this->connected = ! empty($connected);
|
||||
return $this->connected;
|
||||
}
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ class HttpSocket extends CakeSocket {
|
|||
|
||||
$response = null;
|
||||
$inHeader = true;
|
||||
while ($data = $this->read()) {
|
||||
while (($data = $this->read()) !== false) {
|
||||
if ($this->_contentResource) {
|
||||
if ($inHeader) {
|
||||
$response .= $data;
|
||||
|
@ -719,7 +719,7 @@ class HttpSocket extends CakeSocket {
|
|||
unset($this->config[$key]);
|
||||
}
|
||||
if (version_compare(PHP_VERSION, '5.3.2', '>=')) {
|
||||
if (empty($this->config['context']['ssl']['SNI_enabled'])) {
|
||||
if (!isset($this->config['context']['ssl']['SNI_enabled'])) {
|
||||
$this->config['context']['ssl']['SNI_enabled'] = true;
|
||||
}
|
||||
if (version_compare(PHP_VERSION, '5.6.0', '>=')) {
|
||||
|
|
|
@ -952,7 +952,7 @@ EXPECTED;
|
|||
###########################
|
||||
|
||||
EXPECTED;
|
||||
if (php_sapi_name() === 'cli') {
|
||||
if (PHP_SAPI === 'cli') {
|
||||
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18);
|
||||
} else {
|
||||
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 20);
|
||||
|
@ -977,7 +977,7 @@ EXPECTED;
|
|||
###########################
|
||||
|
||||
EXPECTED;
|
||||
if (php_sapi_name() === 'cli') {
|
||||
if (PHP_SAPI === 'cli') {
|
||||
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18);
|
||||
} else {
|
||||
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19);
|
||||
|
@ -1043,7 +1043,7 @@ EXPECTED;
|
|||
* @return void
|
||||
*/
|
||||
public function testPr() {
|
||||
$this->skipIf(php_sapi_name() === 'cli', 'Skipping web test in cli mode');
|
||||
$this->skipIf(PHP_SAPI === 'cli', 'Skipping web test in cli mode');
|
||||
ob_start();
|
||||
pr('this is a test');
|
||||
$result = ob_get_clean();
|
||||
|
@ -1063,7 +1063,7 @@ EXPECTED;
|
|||
* @return void
|
||||
*/
|
||||
public function testPrCli() {
|
||||
$this->skipIf(php_sapi_name() != 'cli', 'Skipping cli test in web mode');
|
||||
$this->skipIf(PHP_SAPI !== 'cli', 'Skipping cli test in web mode');
|
||||
ob_start();
|
||||
pr('this is a test');
|
||||
$result = ob_get_clean();
|
||||
|
|
|
@ -34,7 +34,7 @@ class ApcEngineTest extends CakeTestCase {
|
|||
parent::setUp();
|
||||
$this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.');
|
||||
|
||||
if (php_sapi_name() === 'cli') {
|
||||
if (PHP_SAPI === 'cli') {
|
||||
$this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.');
|
||||
}
|
||||
|
||||
|
|
|
@ -186,6 +186,9 @@ class FixtureTaskTest extends CakeTestCase {
|
|||
$this->Task->interactive = true;
|
||||
$this->Task->expects($this->at(0))->method('in')
|
||||
->will($this->returnValue('WHERE 1=1'));
|
||||
$this->Task->expects($this->at(1))->method('in')
|
||||
->with($this->anything(), $this->anything(), '3')
|
||||
->will($this->returnValue('2'));
|
||||
|
||||
$this->Task->connection = 'test';
|
||||
$this->Task->path = '/my/path/';
|
||||
|
@ -197,9 +200,8 @@ class FixtureTaskTest extends CakeTestCase {
|
|||
$this->assertContains('class ArticleFixture extends CakeTestFixture', $result);
|
||||
$this->assertContains('public $records', $result);
|
||||
$this->assertContains('public $import', $result);
|
||||
$this->assertContains("'title' => 'First Article'", $result, 'Missing import data %s');
|
||||
$this->assertContains('Second Article', $result, 'Missing import data %s');
|
||||
$this->assertContains('Third Article', $result, 'Missing import data %s');
|
||||
$this->assertContains("'title' => 'First Article'", $result, 'Missing import data');
|
||||
$this->assertContains('Second Article', $result, 'Missing import data');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -339,6 +339,32 @@ HTMLBLOC;
|
|||
$this->assertRegExp('/http\:\/\/example\.com/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test send with null properties
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSendNullProperties() {
|
||||
$this->Controller->EmailTest->to = 'test@example.com';
|
||||
$this->Controller->EmailTest->from = 'test@example.com';
|
||||
$this->Controller->EmailTest->subject = null;
|
||||
$this->Controller->EmailTest->replyTo = null;
|
||||
$this->Controller->EmailTest->messageId = null;
|
||||
$this->Controller->EmailTest->template = null;
|
||||
|
||||
$this->Controller->EmailTest->delivery = 'DebugComp';
|
||||
$this->assertTrue($this->Controller->EmailTest->send(null));
|
||||
$result = DebugCompTransport::$lastEmail;
|
||||
|
||||
$this->assertRegExp('/To: test@example.com\n/', $result);
|
||||
$this->assertRegExp('/Subject: \n/', $result);
|
||||
$this->assertRegExp('/From: test@example.com\n/', $result);
|
||||
$this->assertRegExp('/Date: ' . preg_quote(static::$sentDate) . '\n/', $result);
|
||||
$this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result);
|
||||
$this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
|
||||
$this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSendDebug method
|
||||
*
|
||||
|
|
|
@ -1447,6 +1447,25 @@ class ControllerTest extends CakeTestCase {
|
|||
$Controller->invokeAction($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* test invoking controller methods.
|
||||
*
|
||||
* @expectedException PrivateActionException
|
||||
* @expectedExceptionMessage Private Action TestController::Admin_add() is not directly accessible.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvokeActionPrefixProtectionCasing() {
|
||||
Router::reload();
|
||||
Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin'));
|
||||
|
||||
$url = new CakeRequest('test/Admin_add/');
|
||||
$url->addParams(array('controller' => 'test_controller', 'action' => 'Admin_add'));
|
||||
$response = $this->getMock('CakeResponse');
|
||||
|
||||
$Controller = new TestController($url, $response);
|
||||
$Controller->invokeAction($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* test invoking controller methods.
|
||||
*
|
||||
|
|
|
@ -2040,6 +2040,22 @@ class I18nTest extends CakeTestCase {
|
|||
$this->assertSame("saldo", __x('money', 'balance'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic context support using mo files.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testContextMoFile() {
|
||||
Configure::write('Config.language', 'nld_mo');
|
||||
|
||||
$this->assertSame("brief", __x('mail', 'letter'));
|
||||
$this->assertSame("letter", __x('character', 'letter'));
|
||||
$this->assertSame("bal", __x('spherical object', 'ball'));
|
||||
$this->assertSame("danspartij", __x('social gathering', 'ball'));
|
||||
$this->assertSame("balans", __('balance'));
|
||||
$this->assertSame("saldo", __x('money', 'balance'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Singular method
|
||||
*
|
||||
|
|
|
@ -373,7 +373,7 @@ class CakeResponseTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testCompress() {
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
$this->markTestSkipped('The response compression can only be tested in cli.');
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ class CakeResponseTest extends CakeTestCase {
|
|||
if (!extension_loaded("zlib")) {
|
||||
$this->markTestSkipped('Skipping further tests for outputCompressed as zlib extension is not loaded');
|
||||
}
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
$this->markTestSkipped('Testing outputCompressed method with compression enabled done only in cli');
|
||||
}
|
||||
|
||||
|
|
|
@ -307,6 +307,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testRequest() {
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->Socket->reset();
|
||||
|
||||
$response = $this->Socket->request(true);
|
||||
|
@ -589,6 +593,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testGetWithSchemeAndPort() {
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->Socket->reset();
|
||||
$request = array(
|
||||
'uri' => array(
|
||||
|
@ -609,6 +617,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testRequestWithStringQuery() {
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->Socket->reset();
|
||||
$request = array(
|
||||
'uri' => array(
|
||||
|
@ -642,14 +654,18 @@ class HttpSocketTest extends CakeTestCase {
|
|||
*/
|
||||
public function testRequest2() {
|
||||
$this->Socket->reset();
|
||||
|
||||
$request = array('uri' => 'htpp://www.cakephp.org/');
|
||||
$number = mt_rand(0, 9999999);
|
||||
$this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true));
|
||||
$serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>Hello, your lucky number is " . $number . "</h1>";
|
||||
$this->Socket->expects($this->at(0))->method('write')
|
||||
->with("GET / HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n");
|
||||
$this->Socket->expects($this->at(0))->method('read')->will($this->returnValue(false));
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
|
||||
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->onConsecutiveCalls($serverResponse, false));
|
||||
|
||||
$response = (string)$this->Socket->request($request);
|
||||
$this->assertEquals($response, "<h1>Hello, your lucky number is " . $number . "</h1>");
|
||||
}
|
||||
|
@ -662,7 +678,11 @@ class HttpSocketTest extends CakeTestCase {
|
|||
public function testRequest3() {
|
||||
$request = array('uri' => 'htpp://www.cakephp.org/');
|
||||
$serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>This is a cookie test!</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
|
||||
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->onConsecutiveCalls($serverResponse, false));
|
||||
|
||||
$this->Socket->connected = true;
|
||||
$this->Socket->request($request);
|
||||
$result = $this->Socket->response['cookies'];
|
||||
|
@ -711,9 +731,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
*/
|
||||
public function testRequestWithResource() {
|
||||
$serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>This is a test!</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
|
||||
$this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false));
|
||||
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse));
|
||||
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->onConsecutiveCalls($serverResponse, false, $serverResponse, false));
|
||||
$this->Socket->connected = true;
|
||||
|
||||
$f = fopen(TMP . 'download.txt', 'w');
|
||||
|
@ -744,8 +765,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
$this->Socket->config['request']['cookies'] = array();
|
||||
|
||||
$serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>This is a test!</h1>";
|
||||
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
|
||||
$this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false));
|
||||
|
||||
$expected = array('www.cakephp.org' => array('foo' => array('value' => 'bar')));
|
||||
$this->Socket->request('http://www.cakephp.org/');
|
||||
$this->assertEquals($expected, $this->Socket->config['request']['cookies']);
|
||||
|
@ -781,8 +804,9 @@ class HttpSocketTest extends CakeTestCase {
|
|||
public function testRequestCustomResponse() {
|
||||
$this->Socket->connected = true;
|
||||
$serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>This is a test!</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
|
||||
$this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false));
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->onConsecutiveCalls($serverResponse, false));
|
||||
|
||||
$this->Socket->responseClass = 'CustomResponse';
|
||||
$response = $this->Socket->request('http://www.cakephp.org/');
|
||||
|
@ -817,6 +841,8 @@ class HttpSocketTest extends CakeTestCase {
|
|||
$this->Socket->expects($this->at(4))
|
||||
->method('read')
|
||||
->will($this->returnValue($serverResponse2));
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')->will($this->returnValue(false));
|
||||
|
||||
$response = $this->Socket->request($request);
|
||||
$this->assertEquals('<h1>You have been redirected</h1>', $response->body());
|
||||
|
@ -834,8 +860,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
);
|
||||
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false));
|
||||
|
||||
$response = $this->Socket->request($request);
|
||||
$this->assertEquals('<h1>You have been redirected</h1>', $response->body());
|
||||
|
@ -853,8 +881,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
);
|
||||
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false));
|
||||
|
||||
$this->Socket->request($request);
|
||||
$this->assertEquals(1, $this->Socket->request['redirect']);
|
||||
|
@ -872,8 +902,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
);
|
||||
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/oneruri\r\n\r\n";
|
||||
$serverResponse2 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false));
|
||||
|
||||
$response = $this->Socket->request($request);
|
||||
$this->assertEquals(0, $this->Socket->request['redirect']);
|
||||
|
@ -1113,6 +1145,9 @@ class HttpSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testAuth() {
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')->will($this->returnValue(false));
|
||||
|
||||
$this->Socket->get('http://mark:secret@example.com/test');
|
||||
$this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false);
|
||||
|
||||
|
@ -1154,6 +1189,9 @@ class HttpSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testConsecutiveGetResetsAuthCredentials() {
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')->will($this->returnValue(false));
|
||||
|
||||
$this->Socket->get('http://mark:secret@example.com/test');
|
||||
$this->assertEquals('mark', $this->Socket->request['uri']['user']);
|
||||
$this->assertEquals('secret', $this->Socket->request['uri']['pass']);
|
||||
|
@ -1813,6 +1851,9 @@ class HttpSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testConfigContext() {
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')->will($this->returnValue(false));
|
||||
|
||||
$this->Socket->reset();
|
||||
$this->Socket->request('http://example.com');
|
||||
$this->assertTrue($this->Socket->config['context']['ssl']['verify_peer']);
|
||||
|
@ -1869,8 +1910,10 @@ class HttpSocketTest extends CakeTestCase {
|
|||
public function testResponseStatusParsing($status, $code, $msg = '') {
|
||||
$this->Socket->connected = true;
|
||||
$serverResponse = $status . "\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n\r\n<h1>This is a test!</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
|
||||
$this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false));
|
||||
|
||||
$this->Socket->expects($this->any())
|
||||
->method('read')
|
||||
->will($this->onConsecutiveCalls($serverResponse, false));
|
||||
|
||||
$response = $this->Socket->request('http://www.cakephp.org/');
|
||||
$this->assertInstanceOf('HttpSocketResponse', $response);
|
||||
|
|
|
@ -516,8 +516,8 @@ TEXT;
|
|||
Debugger::dump($var);
|
||||
$result = ob_get_clean();
|
||||
|
||||
$open = php_sapi_name() === 'cli' ? "\n" : '<pre>';
|
||||
$close = php_sapi_name() === 'cli' ? "\n" : '</pre>';
|
||||
$open = PHP_SAPI === 'cli' ? "\n" : '<pre>';
|
||||
$close = PHP_SAPI === 'cli' ? "\n" : '</pre>';
|
||||
$expected = <<<TEXT
|
||||
{$open}array(
|
||||
'People' => array(
|
||||
|
@ -540,8 +540,8 @@ TEXT;
|
|||
Debugger::dump($var, 1);
|
||||
$result = ob_get_clean();
|
||||
|
||||
$open = php_sapi_name() === 'cli' ? "\n" : '<pre>';
|
||||
$close = php_sapi_name() === 'cli' ? "\n" : '</pre>';
|
||||
$open = PHP_SAPI === 'cli' ? "\n" : '<pre>';
|
||||
$close = PHP_SAPI === 'cli' ? "\n" : '</pre>';
|
||||
$expected = <<<TEXT
|
||||
{$open}array(
|
||||
'People' => array(
|
||||
|
|
|
@ -583,4 +583,33 @@ class ObjectCollectionTest extends CakeTestCase {
|
|||
$this->assertTrue($this->Objects->trigger($event));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that the various methods ignore plugin prefixes
|
||||
*
|
||||
* plugin prefixes should be removed consistently as load() will
|
||||
* remove them. Furthermore the __get() method does not support
|
||||
* names with '.' in them.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPluginPrefixes() {
|
||||
$this->Objects->load('TestPlugin.First');
|
||||
$this->assertTrue($this->Objects->loaded('First'));
|
||||
$this->assertTrue($this->Objects->loaded('TestPlugin.First'));
|
||||
|
||||
$this->assertTrue($this->Objects->enabled('First'));
|
||||
$this->assertTrue($this->Objects->enabled('TestPlugin.First'));
|
||||
|
||||
$this->assertNull($this->Objects->disable('TestPlugin.First'));
|
||||
$this->assertFalse($this->Objects->enabled('First'));
|
||||
$this->assertFalse($this->Objects->enabled('TestPlugin.First'));
|
||||
|
||||
$this->assertNull($this->Objects->enable('TestPlugin.First'));
|
||||
$this->assertTrue($this->Objects->enabled('First'));
|
||||
$this->assertTrue($this->Objects->enabled('TestPlugin.First'));
|
||||
$this->Objects->setPriority('TestPlugin.First', 1000);
|
||||
|
||||
$result = $this->Objects->prioritize();
|
||||
$this->assertEquals(1000, $result['First'][0]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -930,6 +930,25 @@ class ValidationTest extends CakeTestCase {
|
|||
$this->assertFalse(Validation::comparison(7, '==', 6));
|
||||
$this->assertFalse(Validation::comparison(7, 'not equal', 7));
|
||||
$this->assertFalse(Validation::comparison(7, '!=', 7));
|
||||
|
||||
$this->assertTrue(Validation::comparison('6.5', '!=', 6));
|
||||
$this->assertTrue(Validation::comparison('6.5', '<', 7));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test comparison casting values before comparisons.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testComparisonTypeChecks() {
|
||||
$this->assertFalse(Validation::comparison('\x028', '>=', 1), 'hexish encoding fails');
|
||||
$this->assertFalse(Validation::comparison('0b010', '>=', 1), 'binary string data fails');
|
||||
$this->assertFalse(Validation::comparison('0x01', '>=', 1), 'hex string data fails');
|
||||
$this->assertFalse(Validation::comparison('0x1', '>=', 1), 'hex string data fails');
|
||||
|
||||
$this->assertFalse(Validation::comparison('\x028', '>=', 1.5), 'hexish encoding fails');
|
||||
$this->assertFalse(Validation::comparison('0b010', '>=', 1.5), 'binary string data fails');
|
||||
$this->assertFalse(Validation::comparison('0x02', '>=', 1.5), 'hex string data fails');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2004,6 +2023,22 @@ class ValidationTest extends CakeTestCase {
|
|||
$this->assertFalse(Validation::range('word'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test range type checks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRangeTypeChecks() {
|
||||
$this->assertFalse(Validation::range('\x028', 1, 5), 'hexish encoding fails');
|
||||
$this->assertFalse(Validation::range('0b010', 1, 5), 'binary string data fails');
|
||||
$this->assertFalse(Validation::range('0x01', 1, 5), 'hex string data fails');
|
||||
$this->assertFalse(Validation::range('0x1', 1, 5), 'hex string data fails');
|
||||
|
||||
$this->assertFalse(Validation::range('\x028', 1, 5), 'hexish encoding fails');
|
||||
$this->assertFalse(Validation::range('0b010', 1, 5), 'binary string data fails');
|
||||
$this->assertFalse(Validation::range('0x02', 1, 5), 'hex string data fails');
|
||||
}
|
||||
|
||||
/**
|
||||
* testExtension method
|
||||
*
|
||||
|
|
BIN
lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo
Normal file
BIN
lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo
Normal file
Binary file not shown.
|
@ -176,6 +176,7 @@ abstract class ObjectCollection {
|
|||
public function enable($name, $prioritize = true) {
|
||||
$enabled = false;
|
||||
foreach ((array)$name as $object) {
|
||||
list(, $object) = pluginSplit($object);
|
||||
if (isset($this->_loaded[$object]) && !isset($this->_enabled[$object])) {
|
||||
$priority = $this->defaultPriority;
|
||||
if (isset($this->_loaded[$object]->settings['priority'])) {
|
||||
|
@ -219,6 +220,7 @@ abstract class ObjectCollection {
|
|||
$name = array($name => $priority);
|
||||
}
|
||||
foreach ($name as $object => $objectPriority) {
|
||||
list(, $object) = pluginSplit($object);
|
||||
if (isset($this->_loaded[$object])) {
|
||||
if ($objectPriority === null) {
|
||||
$objectPriority = $this->defaultPriority;
|
||||
|
@ -241,6 +243,7 @@ abstract class ObjectCollection {
|
|||
*/
|
||||
public function disable($name) {
|
||||
foreach ((array)$name as $object) {
|
||||
list(, $object) = pluginSplit($object);
|
||||
unset($this->_enabled[$object]);
|
||||
}
|
||||
}
|
||||
|
@ -255,6 +258,7 @@ abstract class ObjectCollection {
|
|||
*/
|
||||
public function enabled($name = null) {
|
||||
if (!empty($name)) {
|
||||
list(, $name) = pluginSplit($name);
|
||||
return isset($this->_enabled[$name]);
|
||||
}
|
||||
return array_keys($this->_enabled);
|
||||
|
@ -283,6 +287,7 @@ abstract class ObjectCollection {
|
|||
*/
|
||||
public function loaded($name = null) {
|
||||
if (!empty($name)) {
|
||||
list(, $name) = pluginSplit($name);
|
||||
return isset($this->_loaded[$name]);
|
||||
}
|
||||
return array_keys($this->_loaded);
|
||||
|
|
|
@ -242,6 +242,10 @@ class Validation {
|
|||
if (is_array($check1)) {
|
||||
extract($check1, EXTR_OVERWRITE);
|
||||
}
|
||||
|
||||
if ((float)$check1 != $check1) {
|
||||
return false;
|
||||
}
|
||||
$operator = str_replace(array(' ', "\t", "\n", "\r", "\0", "\x0B"), '', strtolower($operator));
|
||||
|
||||
switch ($operator) {
|
||||
|
@ -757,6 +761,9 @@ class Validation {
|
|||
if (!is_numeric($check)) {
|
||||
return false;
|
||||
}
|
||||
if ((float)$check != $check) {
|
||||
return false;
|
||||
}
|
||||
if (isset($lower) && isset($upper)) {
|
||||
return ($check > $lower && $check < $upper);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ HTML;
|
|||
|
||||
TEXT;
|
||||
$template = $html;
|
||||
if (php_sapi_name() === 'cli' || $showHtml === false) {
|
||||
if (PHP_SAPI === 'cli' || $showHtml === false) {
|
||||
$template = $text;
|
||||
if ($showFrom) {
|
||||
$lineInfo = sprintf('%s (line %s)', $file, $line);
|
||||
|
@ -275,7 +275,7 @@ if (!function_exists('pr')) {
|
|||
*/
|
||||
function pr($var) {
|
||||
if (Configure::read('debug') > 0) {
|
||||
$template = php_sapi_name() !== 'cli' ? '<pre>%s</pre>' : "\n%s\n";
|
||||
$template = PHP_SAPI !== 'cli' ? '<pre>%s</pre>' : "\n%s\n";
|
||||
printf($template, print_r($var, true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,17 +172,6 @@ Configure::write('App.imageBaseUrl', IMAGES_URL);
|
|||
Configure::write('App.cssBaseUrl', CSS_URL);
|
||||
Configure::write('App.jsBaseUrl', JS_URL);
|
||||
|
||||
Configure::bootstrap(isset($boot) ? $boot : true);
|
||||
|
||||
if (function_exists('mb_internal_encoding')) {
|
||||
$encoding = Configure::read('App.encoding');
|
||||
if (!empty($encoding)) {
|
||||
mb_internal_encoding($encoding);
|
||||
}
|
||||
if (!empty($encoding) && function_exists('mb_regex_encoding')) {
|
||||
mb_regex_encoding($encoding);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mb_stripos')) {
|
||||
|
||||
|
@ -438,3 +427,15 @@ if (!function_exists('mb_encode_mimeheader')) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
Configure::bootstrap(isset($boot) ? $boot : true);
|
||||
|
||||
if (function_exists('mb_internal_encoding')) {
|
||||
$encoding = Configure::read('App.encoding');
|
||||
if (!empty($encoding)) {
|
||||
mb_internal_encoding($encoding);
|
||||
}
|
||||
if (!empty($encoding) && function_exists('mb_regex_encoding')) {
|
||||
mb_regex_encoding($encoding);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue