Index: branches/RL2/extensions/Gadgets/tests/GadgetPrefsTest.php |
— | — | @@ -3,46 +3,6 @@ |
4 | 4 | * @group Gadgets |
5 | 5 | */ |
6 | 6 | class GadgetPrefsTest extends PHPUnit_Framework_TestCase { |
7 | | - function testPreferences() { |
8 | | - // FIXME this test is broken |
9 | | - $this->markTestIncomplete( 'Broken for now' ); |
10 | | - return; |
11 | | - |
12 | | - global $wgUser; |
13 | | - |
14 | | - // This test makes call to the parser which requires valids Outputpage |
15 | | - // and Title objects. Set them up there, they will be released at the |
16 | | - // end of the test. |
17 | | - global $wgOut, $wgTitle; |
18 | | - $old_wgOut = $wgOut; |
19 | | - $old_wgTitle = $wgTitle; |
20 | | - $wgTitle = Title::newFromText( 'Parser test for Gadgets extension' ); |
21 | | - |
22 | | - // Proceed with test setup: |
23 | | - $prefs = array(); |
24 | | - $context = new RequestContext(); |
25 | | - $wgOut = $context->getOutput(); |
26 | | - $wgOut->setTitle( Title::newFromText( 'test' ) ); |
27 | | - |
28 | | - Gadget::loadStructuredList( '* foo | foo.js |
29 | | -==keep-section1== |
30 | | -* bar| bar.js |
31 | | -==remove-section== |
32 | | -* baz [rights=embezzle] |baz.js |
33 | | -==keep-section2== |
34 | | -* quux [rights=read] | quux.js' ); |
35 | | - $this->assertTrue( GadgetsHooks::getPreferences( $wgUser, $prefs ), 'GetPrefences hook should return true' ); |
36 | | - |
37 | | - $options = $prefs['gadgets']['options']; |
38 | | - $this->assertFalse( isset( $options['<gadget-section-remove-section>'] ), 'Must not show empty sections' ); |
39 | | - $this->assertTrue( isset( $options['<gadget-section-keep-section1>'] ) ); |
40 | | - $this->assertTrue( isset( $options['<gadget-section-keep-section2>'] ) ); |
41 | | - |
42 | | - // Restore globals |
43 | | - $wgOut = $old_wgOut; |
44 | | - $wgTitle = $old_wgTitle; |
45 | | - } |
46 | | - |
47 | 7 | //Test preferences descriptions validator (generic) |
48 | 8 | function testPrefsDescriptions() { |
49 | 9 | $this->assertFalse( GadgetPrefs::isPrefsDescriptionValid( null ) ); |
Index: branches/RL2/extensions/Gadgets/tests/GadgetsTest.php |
— | — | @@ -44,4 +44,44 @@ |
45 | 45 | $this->assertTrue( $g->supportsResourceLoader() ); |
46 | 46 | $this->assertEquals( array( 'jquery.ui' ), $g->getDependencies() ); |
47 | 47 | } |
| 48 | + |
| 49 | + function testPreferences() { |
| 50 | + // FIXME this test is broken |
| 51 | + $this->markTestIncomplete( 'Broken for now' ); |
| 52 | + return; |
| 53 | + |
| 54 | + global $wgUser; |
| 55 | + |
| 56 | + // This test makes call to the parser which requires valid OutputPage |
| 57 | + // and Title objects. Set them up here, they will be released at the |
| 58 | + // end of the test. |
| 59 | + global $wgOut, $wgTitle; |
| 60 | + $old_wgOut = $wgOut; |
| 61 | + $old_wgTitle = $wgTitle; |
| 62 | + $wgTitle = Title::newFromText( 'Parser test for Gadgets extension' ); |
| 63 | + |
| 64 | + // Proceed with test setup: |
| 65 | + $prefs = array(); |
| 66 | + $context = new RequestContext(); |
| 67 | + $wgOut = $context->getOutput(); |
| 68 | + $wgOut->setTitle( Title::newFromText( 'test' ) ); |
| 69 | + |
| 70 | + Gadget::loadStructuredList( '* foo | foo.js |
| 71 | +==keep-section1== |
| 72 | +* bar| bar.js |
| 73 | +==remove-section== |
| 74 | +* baz [rights=embezzle] |baz.js |
| 75 | +==keep-section2== |
| 76 | +* quux [rights=read] | quux.js' ); |
| 77 | + $this->assertTrue( GadgetsHooks::getPreferences( $wgUser, $prefs ), 'GetPrefences hook should return true' ); |
| 78 | + |
| 79 | + $options = $prefs['gadgets']['options']; |
| 80 | + $this->assertFalse( isset( $options['<gadget-section-remove-section>'] ), 'Must not show empty sections' ); |
| 81 | + $this->assertTrue( isset( $options['<gadget-section-keep-section1>'] ) ); |
| 82 | + $this->assertTrue( isset( $options['<gadget-section-keep-section2>'] ) ); |
| 83 | + |
| 84 | + // Restore globals |
| 85 | + $wgOut = $old_wgOut; |
| 86 | + $wgTitle = $old_wgTitle; |
| 87 | + } |
48 | 88 | } |