mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Merge branch '2.x' of https://github.com/cakephp/cakephp into duplicate_primary
This commit is contained in:
commit
02a946b17b
5 changed files with 116 additions and 2 deletions
|
@ -645,6 +645,7 @@ class AuthComponent extends Component {
|
|||
foreach ($this->_authenticateObjects as $auth) {
|
||||
$auth->logout($user);
|
||||
}
|
||||
static::$_user = array();
|
||||
$this->Session->delete(static::$sessionKey);
|
||||
$this->Session->delete('Auth.redirect');
|
||||
$this->Session->renew();
|
||||
|
|
|
@ -1428,6 +1428,23 @@ class AuthComponentTest extends CakeTestCase {
|
|||
$this->assertNull($this->Auth->Session->read('Auth.redirect'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that logout removes the active user data as well for stateless auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLogoutRemoveUser() {
|
||||
$oldKey = AuthComponent::$sessionKey;
|
||||
AuthComponent::$sessionKey = false;
|
||||
$this->Auth->login(array('id' => 1, 'username' => 'mariano'));
|
||||
$this->assertSame('mariano', $this->Auth->user('username'));
|
||||
|
||||
$this->Auth->logout();
|
||||
AuthComponent::$sessionKey = $oldKey;
|
||||
|
||||
$this->assertNull($this->Auth->user('username'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout should trigger a logout method on authentication objects.
|
||||
*
|
||||
|
|
|
@ -6960,6 +6960,34 @@ class ModelReadTest extends BaseModelTest {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test find('list') method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFindListZeroValue() {
|
||||
$this->loadFixtures('Article');
|
||||
|
||||
$model = new Article();
|
||||
$model->displayField = 'title';
|
||||
$model->save(array(
|
||||
'title' => 'Zeroth Article',
|
||||
'user_id' => 0,
|
||||
'published' => 'Y'
|
||||
));
|
||||
|
||||
$result = $model->find('list', array(
|
||||
'fields' => array('title', 'user_id')
|
||||
));
|
||||
$expected = array(
|
||||
'Zeroth Article' => 0,
|
||||
'First Article' => 1,
|
||||
'Second Article' => 3,
|
||||
'Third Article' => 1,
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that find(list) works with array conditions that have only one element.
|
||||
*
|
||||
|
|
|
@ -10734,4 +10734,72 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertAttributeEquals($here, '_lastAction', $this->Form, "_lastAction shouldn't be empty.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the 'errorClass' option when error is returned.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInputErrorClass() {
|
||||
$Contact = ClassRegistry::getObject('Contact');
|
||||
$Contact->validationErrors['field'] = array('Badness!');
|
||||
|
||||
$result = $this->Form->input('Contact.field', array(
|
||||
'type' => 'text',
|
||||
'div' => array('errorClass' => 'has-error')
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text has-error'),
|
||||
'label' => array('for' => 'ContactField'),
|
||||
'Field',
|
||||
'/label',
|
||||
'input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][field]',
|
||||
'id' => 'ContactField', 'class' => 'form-error'
|
||||
),
|
||||
array('div' => array('class' => 'error-message')),
|
||||
'Badness!',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Contact.field', array(
|
||||
'type' => 'text',
|
||||
'error' => array('attributes' => array('class' => 'error'))
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text error'),
|
||||
'label' => array('for' => 'ContactField'),
|
||||
'Field',
|
||||
'/label',
|
||||
'input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][field]',
|
||||
'id' => 'ContactField', 'class' => 'form-error'
|
||||
),
|
||||
array('div' => array('class' => 'error')),
|
||||
'Badness!',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Contact.field', array(
|
||||
'type' => 'text',
|
||||
'div' => array('errorClass' => 'has-error'),
|
||||
'error' => array('attributes' => array('class' => 'form-control-feedback'))
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text has-error'),
|
||||
'label' => array('for' => 'ContactField'),
|
||||
'Field',
|
||||
'/label',
|
||||
'input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][field]',
|
||||
'id' => 'ContactField', 'class' => 'form-error'
|
||||
),
|
||||
array('div' => array('class' => 'form-control-feedback')),
|
||||
'Badness!',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1068,7 +1068,7 @@ class FormHelper extends AppHelper {
|
|||
if ($type !== 'hidden' && $error !== false) {
|
||||
$errMsg = $this->error($fieldName, $error);
|
||||
if ($errMsg) {
|
||||
$divOptions = $this->addClass($divOptions, 'error');
|
||||
$divOptions = $this->addClass($divOptions, Hash::get($divOptions, 'errorClass', 'error'));
|
||||
if ($errorMessage) {
|
||||
$out['error'] = $errMsg;
|
||||
}
|
||||
|
@ -1088,7 +1088,7 @@ class FormHelper extends AppHelper {
|
|||
|
||||
if (!empty($divOptions['tag'])) {
|
||||
$tag = $divOptions['tag'];
|
||||
unset($divOptions['tag']);
|
||||
unset($divOptions['tag'], $divOptions['errorClass']);
|
||||
$output = $this->Html->tag($tag, $output, $divOptions);
|
||||
}
|
||||
return $output;
|
||||
|
|
Loading…
Add table
Reference in a new issue