Index: branches/RL2/extensions/Gadgets/tests/GadgetPrefsTest.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * @group Gadgets |
5 | 5 | */ |
6 | | -class GadgetPrefsTest extends PHPUnit_Framework_TestCase { |
| 6 | +class GadgetPrefsTest extends MediaWikiTestCase { |
7 | 7 | //Test preferences descriptions validator (generic) |
8 | 8 | function testPrefsDescriptions() { |
9 | 9 | $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( null ) ); |
— | — | @@ -825,6 +825,13 @@ |
826 | 826 | 'testSelect2' => 3 |
827 | 827 | ) ); |
828 | 828 | } |
| 829 | + |
| 830 | + private static function createGadgetObject() { |
| 831 | + $gSettings = Gadget::getPropertiesBase(); |
| 832 | + $gSettings['module']['styles'] = array( 'foo.css' ); |
| 833 | + $gSettings['module']['scripts'] = array( 'foo.js' ); |
| 834 | + return new Gadget( 'GadgetsTest', LocalGadgetRepo::singleton(), $gSettings, wfTimestampNow() ); |
| 835 | + } |
829 | 836 | |
830 | 837 | /** |
831 | 838 | * Tests Gadget::setPrefsDescription, GadgetPrefs::checkPrefsAgainstDescription, |
— | — | @@ -834,9 +841,9 @@ |
835 | 842 | */ |
836 | 843 | function testSetPrefs( $prefsDescription ) { |
837 | 844 | // FIXME this test is broken |
838 | | - $this->markTestIncomplete( 'Broken for now' ); |
| 845 | + $this->markTestIncomplete( 'Gadget::setPrefs not yet implemented' ); |
839 | 846 | return; |
840 | | - |
| 847 | + |
841 | 848 | $this->assertTrue( GadgetPrefs::isPrefsDescriptionValid( $prefsDescription ) ); |
842 | 849 | |
843 | 850 | $prefs = array( |
— | — | @@ -865,7 +872,7 @@ |
866 | 873 | $this->assertEquals( $prefs2['testNumber2'], $defaults['testNumber2'] ); |
867 | 874 | $this->assertEquals( $prefs2['testSelect2'], $defaults['testSelect2'] ); |
868 | 875 | |
869 | | - $g = $this->create( '*foo[ResourceLoader]| foo.css|foo.js|foo.bar' ); //FIXME |
| 876 | + $g = self::createGadgetObject(); |
870 | 877 | $g->setPrefsDescription( $prefsDescription ); |
871 | 878 | $this->assertTrue( $g->getPrefsDescription() !== null ); |
872 | 879 | |
— | — | @@ -885,10 +892,10 @@ |
886 | 893 | */ |
887 | 894 | function testSetPrefsWithWrongParam() { |
888 | 895 | // FIXME this test is broken |
889 | | - $this->markTestIncomplete( 'Broken for now' ); |
| 896 | + $this->markTestIncomplete( 'Gadget::setPrefs not yet implemented' ); |
890 | 897 | return; |
891 | 898 | |
892 | | - $g = $this->create( '*foo[ResourceLoader]| foo.css|foo.js|foo.bar' ); //FIXME |
| 899 | + $g = self::createGadgetObject(); |
893 | 900 | $g->setPrefsDescription( array( |
894 | 901 | 'fields' => array( |
895 | 902 | 'testBoolean' => array( |