Skip to content

Commit

Permalink
Unskipped tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Feb 19, 2014
1 parent c4d4731 commit 78debec
Showing 1 changed file with 41 additions and 68 deletions.
109 changes: 41 additions & 68 deletions tests/TestCase/View/Helper/FormHelperTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -926,14 +926,13 @@ public function testCreateWithInputDefaults() {
* @return void * @return void
*/ */
public function testCreateWithAcceptCharset() { public function testCreateWithAcceptCharset() {
$this->markTestIncomplete('Need to revisit once models work again.'); $result = $this->Form->create($this->article, array(
$result = $this->Form->create('UserForm', array( 'type' => 'post', 'action' => 'index', 'encoding' => 'iso-8859-1'
'type' => 'post', 'action' => 'login', 'encoding' => 'iso-8859-1'
) )
); );
$expected = array( $expected = array(
'form' => array( 'form' => array(
'method' => 'post', 'action' => '/user_forms/login', 'id' => 'UserFormLoginForm', 'method' => 'post', 'action' => '/articles',
'accept-charset' => 'iso-8859-1' 'accept-charset' => 'iso-8859-1'
), ),
'div' => array('style' => 'display:none;'), 'div' => array('style' => 'display:none;'),
Expand All @@ -948,9 +947,8 @@ public function testCreateWithAcceptCharset() {
* *
*/ */
public function testCreateQuerystringrequest() { public function testCreateQuerystringrequest() {
$this->markTestIncomplete('Need to revisit once models work again.');
$encoding = strtolower(Configure::read('App.encoding')); $encoding = strtolower(Configure::read('App.encoding'));
$result = $this->Form->create('Contact', array( $result = $this->Form->create($this->article, array(
'type' => 'post', 'type' => 'post',
'escape' => false, 'escape' => false,
'url' => array( 'url' => array(
Expand All @@ -961,7 +959,6 @@ public function testCreateQuerystringrequest() {
)); ));
$expected = array( $expected = array(
'form' => array( 'form' => array(
'id' => 'ContactAddForm',
'method' => 'post', 'method' => 'post',
'action' => '/controller/action?param1=value1&param2=value2', 'action' => '/controller/action?param1=value1&param2=value2',
'accept-charset' => $encoding 'accept-charset' => $encoding
Expand All @@ -972,7 +969,7 @@ public function testCreateQuerystringrequest() {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);


$result = $this->Form->create('Contact', array( $result = $this->Form->create($this->article, array(
'type' => 'post', 'type' => 'post',
'url' => array( 'url' => array(
'controller' => 'controller', 'controller' => 'controller',
Expand All @@ -982,7 +979,6 @@ public function testCreateQuerystringrequest() {
)); ));
$expected = array( $expected = array(
'form' => array( 'form' => array(
'id' => 'ContactAddForm',
'method' => 'post', 'method' => 'post',
'action' => '/controller/action?param1=value1&param2=value2', 'action' => '/controller/action?param1=value1&param2=value2',
'accept-charset' => $encoding 'accept-charset' => $encoding
Expand All @@ -1001,16 +997,14 @@ public function testCreateQuerystringrequest() {
* @return void * @return void
*/ */
public function testCreateWithMultipleIdInData() { public function testCreateWithMultipleIdInData() {
$this->markTestIncomplete('Need to revisit once models work again.');
$encoding = strtolower(Configure::read('App.encoding')); $encoding = strtolower(Configure::read('App.encoding'));


$this->Form->request->data['Contact']['id'] = array(1, 2); $this->Form->request->data['Article']['id'] = array(1, 2);
$result = $this->Form->create('Contact'); $result = $this->Form->create($this->article);
$expected = array( $expected = array(
'form' => array( 'form' => array(
'id' => 'ContactAddForm',
'method' => 'post', 'method' => 'post',
'action' => '/contacts/add', 'action' => '/articles/add',
'accept-charset' => $encoding 'accept-charset' => $encoding
), ),
'div' => array('style' => 'display:none;'), 'div' => array('style' => 'display:none;'),
Expand All @@ -1026,10 +1020,9 @@ public function testCreateWithMultipleIdInData() {
* @return void * @return void
*/ */
public function testCreatePassedArgs() { public function testCreatePassedArgs() {
$this->markTestIncomplete('Need to revisit once models work again.');
$encoding = strtolower(Configure::read('App.encoding')); $encoding = strtolower(Configure::read('App.encoding'));
$this->Form->request->data['Contact']['id'] = 1; $this->Form->request->data['Article']['id'] = 1;
$result = $this->Form->create('Contact', array( $result = $this->Form->create($this->article, array(
'type' => 'post', 'type' => 'post',
'escape' => false, 'escape' => false,
'url' => array( 'url' => array(
Expand All @@ -1039,9 +1032,8 @@ public function testCreatePassedArgs() {
)); ));
$expected = array( $expected = array(
'form' => array( 'form' => array(
'id' => 'ContactAddForm',
'method' => 'post', 'method' => 'post',
'action' => '/contacts/edit/myparam', 'action' => '/articles/edit/myparam',
'accept-charset' => $encoding 'accept-charset' => $encoding
), ),
'div' => array('style' => 'display:none;'), 'div' => array('style' => 'display:none;'),
Expand All @@ -1057,28 +1049,27 @@ public function testCreatePassedArgs() {
* @return void * @return void
*/ */
public function testGetFormCreate() { public function testGetFormCreate() {
$this->markTestIncomplete('Need to revisit once models work again.');
$encoding = strtolower(Configure::read('App.encoding')); $encoding = strtolower(Configure::read('App.encoding'));
$result = $this->Form->create('Contact', array('type' => 'get')); $result = $this->Form->create($this->article, array('type' => 'get'));
$this->assertTags($result, array('form' => array( $this->assertTags($result, array('form' => array(
'id' => 'ContactAddForm', 'method' => 'get', 'action' => '/contacts/add', 'method' => 'get', 'action' => '/articles/add',
'accept-charset' => $encoding 'accept-charset' => $encoding
))); )));


$result = $this->Form->text('Contact.name'); $result = $this->Form->text('title');
$this->assertTags($result, array('input' => array( $this->assertTags($result, array('input' => array(
'name' => 'name', 'type' => 'text', 'id' => 'ContactName', 'name' => 'title', 'type' => 'text', 'required' => 'required'
))); )));


$result = $this->Form->password('password'); $result = $this->Form->password('password');
$this->assertTags($result, array('input' => array( $this->assertTags($result, array('input' => array(
'name' => 'password', 'type' => 'password', 'id' => 'ContactPassword' 'name' => 'password', 'type' => 'password'
))); )));
$this->assertNotRegExp('/<input[^<>]+[^id|name|type|value]=[^<>]*>$/', $result); $this->assertNotRegExp('/<input[^<>]+[^id|name|type|value]=[^<>]*>$/', $result);


$result = $this->Form->text('user_form'); $result = $this->Form->text('user_form');
$this->assertTags($result, array('input' => array( $this->assertTags($result, array('input' => array(
'name' => 'user_form', 'type' => 'text', 'id' => 'ContactUserForm' 'name' => 'user_form', 'type' => 'text'
))); )));
} }


Expand All @@ -1088,20 +1079,21 @@ public function testGetFormCreate() {
* @return void * @return void
*/ */
public function testGetFormWithFalseModel() { public function testGetFormWithFalseModel() {
$this->markTestIncomplete('Need to revisit once models work again.');
$encoding = strtolower(Configure::read('App.encoding')); $encoding = strtolower(Configure::read('App.encoding'));
$this->Form->request['controller'] = 'contact_test'; $this->Form->request['controller'] = 'contact_test';
$result = $this->Form->create(false, array('type' => 'get', 'url' => array('controller' => 'contact_test'))); $result = $this->Form->create(false, array(
'type' => 'get', 'url' => array('controller' => 'contact_test')
));


$expected = array('form' => array( $expected = array('form' => array(
'id' => 'addForm', 'method' => 'get', 'action' => '/contact_test/add', 'method' => 'get', 'action' => '/contact_test/add',
'accept-charset' => $encoding 'accept-charset' => $encoding
)); ));
$this->assertTags($result, $expected); $this->assertTags($result, $expected);


$result = $this->Form->text('reason'); $result = $this->Form->text('reason');
$expected = array( $expected = array(
'input' => array('type' => 'text', 'name' => 'reason', 'id' => 'reason') 'input' => array('type' => 'text', 'name' => 'reason')
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
Expand Down Expand Up @@ -1485,11 +1477,9 @@ public function testSecurityButtonNestedNamed() {
* @return void * @return void
*/ */
public function testSecuritySubmitNestedNamed() { public function testSecuritySubmitNestedNamed() {
$this->markTestIncomplete('Need to revisit once models work again.'); $this->Form->request->params['_Token'] = 'testKey';
$key = 'testKey';
$this->Form->request->params['_csrfToken'] = $key;


$this->Form->create('Addresses'); $this->Form->create($this->article);
$this->Form->submit('Test', array('type' => 'submit', 'name' => 'Address[button]')); $this->Form->submit('Test', array('type' => 'submit', 'name' => 'Address[button]'));
$result = $this->Form->unlockField(); $result = $this->Form->unlockField();
$this->assertEquals(array('Address.button'), $result); $this->assertEquals(array('Address.button'), $result);
Expand All @@ -1501,11 +1491,10 @@ public function testSecuritySubmitNestedNamed() {
* @return void * @return void
*/ */
public function testSecuritySubmitImageNoName() { public function testSecuritySubmitImageNoName() {
$this->markTestIncomplete('Need to revisit once models work again.');
$key = 'testKey'; $key = 'testKey';
$this->Form->request->params['_csrfToken'] = $key; $this->Form->request->params['_Token'] = 'testKey';


$this->Form->create('User'); $this->Form->create(false);
$result = $this->Form->submit('save.png'); $result = $this->Form->submit('save.png');
$expected = array( $expected = array(
'div' => array('class' => 'submit'), 'div' => array('class' => 'submit'),
Expand All @@ -1522,11 +1511,9 @@ public function testSecuritySubmitImageNoName() {
* @return void * @return void
*/ */
public function testSecuritySubmitImageName() { public function testSecuritySubmitImageName() {
$this->markTestIncomplete('Need to revisit once models work again.'); $this->Form->request->params['_Token'] = 'testKey';
$key = 'testKey';
$this->Form->request->params['_csrfToken'] = $key;


$this->Form->create('User'); $this->Form->create(null);
$result = $this->Form->submit('save.png', array('name' => 'test')); $result = $this->Form->submit('save.png', array('name' => 'test'));
$expected = array( $expected = array(
'div' => array('class' => 'submit'), 'div' => array('class' => 'submit'),
Expand Down Expand Up @@ -1710,8 +1697,7 @@ public function testFormSecurityInputUnlockedFields() {
* @return void * @return void
*/ */
public function testFormSecureWithCustomNameAttribute() { public function testFormSecureWithCustomNameAttribute() {
$this->markTestIncomplete('Need to revisit once models work again.'); $this->Form->request->params['_Token'] = 'testKey';
$this->Form->request->params['_csrfToken'] = 'testKey';


$this->Form->text('UserForm.published', array('name' => 'User[custom]')); $this->Form->text('UserForm.published', array('name' => 'User[custom]'));
$this->assertEquals('User.custom', $this->Form->fields[0]); $this->assertEquals('User.custom', $this->Form->fields[0]);
Expand Down Expand Up @@ -1901,7 +1887,6 @@ public function testFormSecuredFileInput() {
* @return void * @return void
*/ */
public function testFormSecuredMultipleSelect() { public function testFormSecuredMultipleSelect() {
$this->markTestIncomplete('Need to revisit once models work again.');
$this->Form->request->params['_csrfToken'] = 'testKey'; $this->Form->request->params['_csrfToken'] = 'testKey';
$this->assertEquals(array(), $this->Form->fields); $this->assertEquals(array(), $this->Form->fields);
$options = array('1' => 'one', '2' => 'two'); $options = array('1' => 'one', '2' => 'two');
Expand Down Expand Up @@ -1935,7 +1920,6 @@ public function testFormSecuredRadio() {
* @return void * @return void
*/ */
public function testFormSecuredAndDisabledNotAssoc() { public function testFormSecuredAndDisabledNotAssoc() {
$this->markTestIncomplete('Need to revisit once models work again.');
$this->Form->request->params['_csrfToken'] = 'testKey'; $this->Form->request->params['_csrfToken'] = 'testKey';


$this->Form->select('Model.select', array(1, 2), array('disabled')); $this->Form->select('Model.select', array(1, 2), array('disabled'));
Expand All @@ -1958,7 +1942,6 @@ public function testFormSecuredAndDisabledNotAssoc() {
* @return void * @return void
*/ */
public function testFormSecuredAndDisabled() { public function testFormSecuredAndDisabled() {
$this->markTestIncomplete('Need to revisit once models work again.');
$this->Form->request->params['_csrfToken'] = 'testKey'; $this->Form->request->params['_csrfToken'] = 'testKey';


$this->Form->checkbox('Model.checkbox', array('disabled' => true)); $this->Form->checkbox('Model.checkbox', array('disabled' => true));
Expand Down Expand Up @@ -2014,12 +1997,9 @@ public function testDisableSecurityUsingForm() {
* @return void * @return void
*/ */
public function testUnlockFieldAddsToList() { public function testUnlockFieldAddsToList() {
$this->markTestIncomplete('Need to revisit once models work again.');
$this->Form->request->params['_csrfToken'] = 'testKey';
$this->Form->request['_Token'] = array( $this->Form->request['_Token'] = array(
'unlockedFields' => array() 'unlockedFields' => array()
); );
$this->Form->create('Contact');
$this->Form->unlockField('Contact.name'); $this->Form->unlockField('Contact.name');
$this->Form->text('Contact.name'); $this->Form->text('Contact.name');


Expand All @@ -2033,20 +2013,18 @@ public function testUnlockFieldAddsToList() {
* @return void * @return void
*/ */
public function testUnlockFieldRemovingFromFields() { public function testUnlockFieldRemovingFromFields() {
$this->markTestIncomplete('Need to revisit once models work again.');
$this->Form->request->params['_csrfToken'] = 'testKey';
$this->Form->request['_Token'] = array( $this->Form->request['_Token'] = array(
'unlockedFields' => array() 'unlockedFields' => array()
); );
$this->Form->create('Contact'); $this->Form->create($this->article);
$this->Form->hidden('Contact.id', array('value' => 1)); $this->Form->hidden('Article.id', array('value' => 1));
$this->Form->text('Contact.name'); $this->Form->text('Article.title');


$this->assertEquals(1, $this->Form->fields['Contact.id'], 'Hidden input should be secured.'); $this->assertEquals(1, $this->Form->fields['Article.id'], 'Hidden input should be secured.');
$this->assertTrue(in_array('Contact.name', $this->Form->fields), 'Field should be secured.'); $this->assertTrue(in_array('Article.title', $this->Form->fields), 'Field should be secured.');


$this->Form->unlockField('Contact.name'); $this->Form->unlockField('Article.title');
$this->Form->unlockField('Contact.id'); $this->Form->unlockField('Article.id');
$this->assertEquals(array(), $this->Form->fields); $this->assertEquals(array(), $this->Form->fields);
} }


Expand Down Expand Up @@ -4039,22 +4017,21 @@ public function testTextDefaultValue() {
* @return void * @return void
*/ */
public function testCheckboxDefaultValue() { public function testCheckboxDefaultValue() {
$this->markTestIncomplete('Need to revisit once models work again.');
$this->Form->request->data['Model']['field'] = false; $this->Form->request->data['Model']['field'] = false;
$result = $this->Form->checkbox('Model.field', array('default' => true, 'hiddenField' => false)); $result = $this->Form->checkbox('Model.field', array('default' => true, 'hiddenField' => false));
$this->assertTags($result, array('input' => array('type' => 'checkbox', 'name' => 'Model[field]', 'value' => '1', 'id' => 'ModelField'))); $this->assertTags($result, array('input' => array('type' => 'checkbox', 'name' => 'Model[field]', 'value' => '1')));


unset($this->Form->request->data['Model']['field']); unset($this->Form->request->data['Model']['field']);
$result = $this->Form->checkbox('Model.field', array('default' => true, 'hiddenField' => false)); $result = $this->Form->checkbox('Model.field', array('default' => true, 'hiddenField' => false));
$this->assertTags($result, array('input' => array('type' => 'checkbox', 'name' => 'Model[field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))); $this->assertTags($result, array('input' => array('type' => 'checkbox', 'name' => 'Model[field]', 'value' => '1', 'checked' => 'checked')));


$this->Form->request->data['Model']['field'] = true; $this->Form->request->data['Model']['field'] = true;
$result = $this->Form->checkbox('Model.field', array('default' => false, 'hiddenField' => false)); $result = $this->Form->checkbox('Model.field', array('default' => false, 'hiddenField' => false));
$this->assertTags($result, array('input' => array('type' => 'checkbox', 'name' => 'Model[field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))); $this->assertTags($result, array('input' => array('type' => 'checkbox', 'name' => 'Model[field]', 'value' => '1', 'checked' => 'checked')));


unset($this->Form->request->data['Model']['field']); unset($this->Form->request->data['Model']['field']);
$result = $this->Form->checkbox('Model.field', array('default' => false, 'hiddenField' => false)); $result = $this->Form->checkbox('Model.field', array('default' => false, 'hiddenField' => false));
$this->assertTags($result, array('input' => array('type' => 'checkbox', 'name' => 'Model[field]', 'value' => '1', 'id' => 'ModelField'))); $this->assertTags($result, array('input' => array('type' => 'checkbox', 'name' => 'Model[field]', 'value' => '1')));
} }


/** /**
Expand Down Expand Up @@ -6912,7 +6889,6 @@ public function testPostLinkFormBuffer() {
* @return void * @return void
*/ */
public function testSubmitButton() { public function testSubmitButton() {
$this->markTestIncomplete('Need to revisit once models work again.');
$result = $this->Form->submit(''); $result = $this->Form->submit('');
$expected = array( $expected = array(
'div' => array('class' => 'submit'), 'div' => array('class' => 'submit'),
Expand Down Expand Up @@ -7010,7 +6986,6 @@ public function testSubmitButton() {
* @return void * @return void
*/ */
public function testSubmitImage() { public function testSubmitImage() {
$this->markTestIncomplete('Need to revisit once models work again.');
$result = $this->Form->submit('http://example.com/cake.power.gif'); $result = $this->Form->submit('http://example.com/cake.power.gif');
$expected = array( $expected = array(
'div' => array('class' => 'submit'), 'div' => array('class' => 'submit'),
Expand Down Expand Up @@ -7091,8 +7066,7 @@ public function testSubmitImage() {
* @return void * @return void
*/ */
public function testSubmitUnlockedByDefault() { public function testSubmitUnlockedByDefault() {
$this->markTestIncomplete('Need to revisit once models work again.'); $this->Form->request->params['_Token'] = 'secured';
$this->Form->request->params['_csrfToken'] = 'secured';
$this->Form->submit('Go go'); $this->Form->submit('Go go');
$this->Form->submit('Save', array('name' => 'save')); $this->Form->submit('Save', array('name' => 'save'));


Expand All @@ -7106,7 +7080,6 @@ public function testSubmitUnlockedByDefault() {
* @return void * @return void
*/ */
public function testSubmitImageTimestamp() { public function testSubmitImageTimestamp() {
$this->markTestIncomplete('Need to revisit once models work again.');
Configure::write('Asset.timestamp', 'force'); Configure::write('Asset.timestamp', 'force');


$result = $this->Form->submit('cake.power.gif'); $result = $this->Form->submit('cake.power.gif');
Expand Down

0 comments on commit 78debec

Please sign in to comment.