Skip to content
This repository
Browse code

Starting to update tests after removing the validationErrors property…

… in Helper
  • Loading branch information...
commit d54e8cd82f2e77ea1883a5a49c20aa288724fc82 1 parent 39dadf5
José Lorenzo Rodríguez authored July 13, 2011
62  lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -1361,7 +1361,9 @@ public function testUnlockFieldRemovingFromFields() {
1361 1361
  * @return void
1362 1362
  */
1363 1363
 	public function testPasswordValidation() {
1364  
-		$this->Form->validationErrors['Contact']['password'] = array('Please provide a password');
  1364
+		$Contact = ClassRegistry::getObject('Contact');
  1365
+		$Contact->validationErrors['password'] =  array('Please provide a password');
  1366
+
1365 1367
 		$result = $this->Form->input('Contact.password');
1366 1368
 		$expected = array(
1367 1369
 			'div' => array('class' => 'input password error'),
@@ -1414,9 +1416,6 @@ public function testFormValidationAssociated() {
1414 1416
 		);
1415 1417
 		$this->assertTags($result, $expected);
1416 1418
 
1417  
-		$expected = array('OpenidUrl' => array('openid_not_registered' => array(true)));
1418  
-		$this->assertEqual($this->Form->validationErrors, $expected);
1419  
-
1420 1419
 		$result = $this->Form->error(
1421 1420
 			'OpenidUrl.openid_not_registered', 'Error, not registered', array('wrap' => false)
1422 1421
 		);
@@ -1457,11 +1456,20 @@ public function testFormValidationAssociatedFirstLevel() {
1457 1456
 		);
1458 1457
 		$this->assertTags($result, $expected);
1459 1458
 
1460  
-		$expected = array(
1461  
-			'ValidateUser' => array('email' => array(true)),
1462  
-			'ValidateProfile' => array('full_name' => array(true), 'city' => array(true))
  1459
+		$result = $this->Form->error(
  1460
+			'ValidateUser.email', 'Invalid email', array('wrap' => false)
  1461
+		);
  1462
+		$this->assertEqual($result, 'Invalid email');
  1463
+
  1464
+		$result = $this->Form->error(
  1465
+			'ValidateProfile.full_name', 'Invalid name', array('wrap' => false)
  1466
+		);
  1467
+		$this->assertEqual($result, 'Invalid name');
  1468
+
  1469
+		$result = $this->Form->error(
  1470
+			'ValidateProfile.city', 'Invalid city', array('wrap' => false)
1463 1471
 		);
1464  
-		$this->assertEqual($this->Form->validationErrors, $expected);
  1472
+		$this->assertEqual($result, 'Invalid city');
1465 1473
 
1466 1474
 		unset($this->ValidateUser->ValidateProfile);
1467 1475
 		unset($this->ValidateUser);
@@ -1501,13 +1509,25 @@ public function testFormValidationAssociatedSecondLevel() {
1501 1509
 			'/div'
1502 1510
 		);
1503 1511
 		$this->assertTags($result, $expected);
  1512
+		
  1513
+		$result = $this->Form->error(
  1514
+			'ValidateUser.email', 'Invalid email', array('wrap' => false)
  1515
+		);
  1516
+		$this->assertEqual($result, 'Invalid email');
1504 1517
 
1505  
-		$expected = array(
1506  
-			'ValidateUser' => array('email' => array(true)),
1507  
-			'ValidateProfile' => array('full_name' => array(true), 'city' => array(true)),
1508  
-			'ValidateItem' => array('description' => array(true))
  1518
+		$result = $this->Form->error(
  1519
+			'ValidateProfile.full_name', 'Invalid name', array('wrap' => false)
  1520
+		);
  1521
+		$this->assertEqual($result, 'Invalid name');
  1522
+
  1523
+		$result = $this->Form->error(
  1524
+			'ValidateProfile.city', 'Invalid city', array('wrap' => false)
  1525
+		);
  1526
+
  1527
+		$result = $this->Form->error(
  1528
+			'ValidateItem.description', 'Invalid description', array('wrap' => false)
1509 1529
 		);
1510  
-		$this->assertEqual($this->Form->validationErrors, $expected);
  1530
+		$this->assertEqual($result, 'Invalid description');
1511 1531
 
1512 1532
 		unset($this->ValidateUser->ValidateProfile->ValidateItem);
1513 1533
 		unset($this->ValidateUser->ValidateProfile);
@@ -1523,9 +1543,10 @@ public function testFormValidationAssociatedSecondLevel() {
1523 1543
  * @return void
1524 1544
  */
1525 1545
 	public function testFormValidationMultiRecord() {
1526  
-		$this->Form->validationErrors['Contact'] = array(2 => array(
  1546
+		$Contact = ClassRegistry::getObject('Contact');
  1547
+		$Contact->validationErrors[2] = array(
1527 1548
 			'name' => array('This field cannot be left blank')
1528  
-		));
  1549
+		);
1529 1550
 		$result = $this->Form->input('Contact.2.name');
1530 1551
 		$expected = array(
1531 1552
 			'div' => array('class' => 'input text error'),
@@ -1553,10 +1574,15 @@ public function testFormValidationMultiRecord() {
1553 1574
  * @return void
1554 1575
  */
1555 1576
 	public function testMultipleInputValidation() {
  1577
+		$Address = ClassRegistry::getObject('Address');
  1578
+		$Address->validationErrors[0] = array(
  1579
+			'title' => array('This field cannot be empty'),
  1580
+			'first_name' => array('This field cannot be empty')
  1581
+		);
  1582
+		$Address->validationErrors[1] = array(
  1583
+			'last_name' => array('You must have a last name')
  1584
+		);
1556 1585
 		$this->Form->create();
1557  
-		$this->Form->validationErrors['Address'][0]['title'] = array('This field cannot be empty');
1558  
-		$this->Form->validationErrors['Address'][0]['first_name'] = array('This field cannot be empty');
1559  
-		$this->Form->validationErrors['Address'][1]['last_name'] = array('You must have a last name');
1560 1586
 
1561 1587
 		$result = $this->Form->input('Address.0.title');
1562 1588
 		$expected = array(

0 notes on commit d54e8cd

Please sign in to comment.
Something went wrong with that request. Please try again.