@@ 752-789 (lines=38) @@ | ||
749 | * |
|
750 | * @return void |
|
751 | */ |
|
752 | public function testGetFieldAttribute() |
|
753 | { |
|
754 | $form = new JFormInspector('form1'); |
|
755 | ||
756 | $this->assertThat( |
|
757 | $form->load(JFormDataHelper::$getFieldDocument), |
|
758 | $this->isTrue(), |
|
759 | 'Line:' . __LINE__ . ' XML string should load successfully.' |
|
760 | ); |
|
761 | ||
762 | // Test error handling. |
|
763 | ||
764 | $this->assertThat( |
|
765 | $form->getFieldAttribute('bogus', 'unknown', 'Help'), |
|
766 | $this->equalTo('Help'), |
|
767 | 'Line:' . __LINE__ . ' The default value of the unknown field should be returned.' |
|
768 | ); |
|
769 | ||
770 | $this->assertThat( |
|
771 | $form->getFieldAttribute('title', 'unknown', 'Use this'), |
|
772 | $this->equalTo('Use this'), |
|
773 | 'Line:' . __LINE__ . ' The default value of the unknown attribute should be returned.' |
|
774 | ); |
|
775 | ||
776 | // Test general usage. |
|
777 | ||
778 | $this->assertThat( |
|
779 | $form->getFieldAttribute('title', 'description'), |
|
780 | $this->equalTo('The title.'), |
|
781 | 'Line:' . __LINE__ . ' The value of the attribute should be returned.' |
|
782 | ); |
|
783 | ||
784 | $this->assertThat( |
|
785 | $form->getFieldAttribute('title', 'description', 'Use this'), |
|
786 | $this->equalTo('The title.'), |
|
787 | 'Line:' . __LINE__ . ' The value of the attribute should be returned.' |
|
788 | ); |
|
789 | } |
|
790 | ||
791 | /** |
|
792 | * Test the Form::getFormControl method. |
|
@@ 1674-1707 (lines=34) @@ | ||
1671 | * |
|
1672 | * @return void |
|
1673 | */ |
|
1674 | public function testSetFieldAttribute() |
|
1675 | { |
|
1676 | $form = new JFormInspector('form1'); |
|
1677 | ||
1678 | $this->assertThat( |
|
1679 | $form->load(JFormDataHelper::$loadDocument), |
|
1680 | $this->isTrue(), |
|
1681 | 'Line:' . __LINE__ . ' XML string should load successfully.' |
|
1682 | ); |
|
1683 | ||
1684 | $this->assertThat( |
|
1685 | $form->setFieldAttribute('title', 'label', 'The Title'), |
|
1686 | $this->isTrue(), |
|
1687 | 'Line:' . __LINE__ . ' The method should return true.' |
|
1688 | ); |
|
1689 | ||
1690 | $this->assertThat( |
|
1691 | $form->getFieldAttribute('title', 'label'), |
|
1692 | $this->equalTo('The Title'), |
|
1693 | 'Line:' . __LINE__ . ' The new value should be set.' |
|
1694 | ); |
|
1695 | ||
1696 | $this->assertThat( |
|
1697 | $form->setFieldAttribute('show_title', 'label', 'Show Title', 'params'), |
|
1698 | $this->isTrue(), |
|
1699 | 'Line:' . __LINE__ . ' The method should return true.' |
|
1700 | ); |
|
1701 | ||
1702 | $this->assertThat( |
|
1703 | $form->getFieldAttribute('show_title', 'label', 'default', 'params'), |
|
1704 | $this->equalTo('Show Title'), |
|
1705 | 'Line:' . __LINE__ . ' The new value of the grouped field should be set.' |
|
1706 | ); |
|
1707 | } |
|
1708 | ||
1709 | /** |
|
1710 | * Test for Form::setFields method. |