Merge branch '2.x' into 2.next

This commit is contained in:
mark_story 2016-11-06 21:42:31 -05:00
commit c0150f62ed
4 changed files with 39 additions and 10 deletions

View file

@ -90,7 +90,7 @@ class Component extends CakeObject {
*/
public function __get($name) {
if (isset($this->_componentMap[$name]) && !isset($this->{$name})) {
$settings = array('enabled' => false) + (array)$this->_componentMap[$name]['settings'];
$settings = (array)$this->_componentMap[$name]['settings'] + array('enabled' => false);
$this->{$name} = $this->_Collection->load($this->_componentMap[$name]['class'], $settings);
}
if (isset($this->{$name})) {

View file

@ -319,7 +319,11 @@ class HttpSocketResponse implements ArrayAccess {
$parts = preg_split('/\;[ \t]*/', $cookie);
}
list($name, $value) = explode('=', array_shift($parts), 2);
$nameParts = explode('=', array_shift($parts), 2);
if (count($nameParts) < 2) {
$nameParts = array('', $nameParts[0]);
}
list($name, $value) = $nameParts;
$cookies[$name] = compact('value');
foreach ($parts as $part) {

View file

@ -31,7 +31,10 @@ class ParamTestComponent extends Component {
*
* @var array
*/
public $components = array('Banana' => array('config' => 'value'));
public $components = array(
'Apple' => array('enabled' => true),
'Banana' => array('config' => 'value'),
);
}
/**
@ -286,4 +289,17 @@ class ComponentTest extends CakeTestCase {
$this->assertInstanceOf('EmailComponent', $Controller->SomethingWithEmail->Email);
}
/**
* Test lazy loading of components inside components and both explicit and
* implicit 'enabled' setting.
*
* @return void
*/
public function testGet() {
$Collection = new ComponentCollection();
$ParamTest = $Collection->load('ParamTest');
$this->assertTrue($ParamTest->Apple->settings['enabled']);
$this->assertFalse($ParamTest->Banana->settings['enabled']);
}
}

View file

@ -480,7 +480,9 @@ class HttpResponseTest extends CakeTestCase {
'Set-Cookie' => array(
'foo=bar',
'people=jim,jack,johnny";";Path=/accounts',
'google=not=nice'
'google=not=nice',
'1271; domain=.example.com; expires=Fri, 04-Nov-2016 12:50:26 GMT; path=/',
'cakephp=great; Secure'
),
'Transfer-Encoding' => 'chunked',
'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT',
@ -496,17 +498,24 @@ class HttpResponseTest extends CakeTestCase {
),
'google' => array(
'value' => 'not=nice',
),
'' => array(
'value' => '1271',
'domain' => '.example.com',
'expires' => 'Fri, 04-Nov-2016 12:50:26 GMT',
'path' => '/'
),
'cakephp' => array(
'value' => 'great',
'secure' => true,
)
);
$this->assertEquals($expected, $cookies);
$header['Set-Cookie'][] = 'cakephp=great; Secure';
$expected['cakephp'] = array('value' => 'great', 'secure' => true);
$cookies = $this->HttpResponse->parseCookies($header);
$this->assertEquals($expected, $cookies);
$header['Set-Cookie'] = 'foo=bar';
unset($expected['people'], $expected['cakephp'], $expected['google']);
$expected = array(
'foo' => array('value' => 'bar')
);
$cookies = $this->HttpResponse->parseCookies($header);
$this->assertEquals($expected, $cookies);
}