Merge "SpecialMovepage: Convert form to use OOUI controls"
[lhc/web/wiklou.git] / tests / phpunit / includes / TestingAccessWrapperTest.php
1 <?php
2
3 class TestingAccessWrapperTest extends MediaWikiTestCase {
4 protected $raw;
5 protected $wrapped;
6
7 function setUp() {
8 parent::setUp();
9
10 require_once __DIR__ . '/../data/helpers/WellProtectedClass.php';
11 $this->raw = new WellProtectedClass();
12 $this->wrapped = TestingAccessWrapper::newFromObject( $this->raw );
13 }
14
15 function testGetProperty() {
16 $this->assertSame( 1, $this->wrapped->property );
17 $this->assertSame( 42, $this->wrapped->privateProperty );
18 $this->assertSame( 9000, $this->wrapped->privateParentProperty );
19 }
20
21 function testSetProperty() {
22 $this->wrapped->property = 10;
23 $this->assertSame( 10, $this->wrapped->property );
24 $this->assertSame( 10, $this->raw->getProperty() );
25
26 $this->wrapped->privateProperty = 11;
27 $this->assertSame( 11, $this->wrapped->privateProperty );
28 $this->assertSame( 11, $this->raw->getPrivateProperty() );
29
30 $this->wrapped->privateParentProperty = 12;
31 $this->assertSame( 12, $this->wrapped->privateParentProperty );
32 $this->assertSame( 12, $this->raw->getPrivateParentProperty() );
33 }
34
35 function testCallMethod() {
36 $this->wrapped->incrementPropertyValue();
37 $this->assertSame( 2, $this->wrapped->property );
38 $this->assertSame( 2, $this->raw->getProperty() );
39
40 $this->wrapped->incrementPrivatePropertyValue();
41 $this->assertSame( 43, $this->wrapped->privateProperty );
42 $this->assertSame( 43, $this->raw->getPrivateProperty() );
43
44 $this->wrapped->incrementPrivateParentPropertyValue();
45 $this->assertSame( 9001, $this->wrapped->privateParentProperty );
46 $this->assertSame( 9001, $this->raw->getPrivateParentProperty() );
47 }
48
49 function testCallMethodTwoArgs() {
50 $this->assertSame( 'two', $this->wrapped->whatSecondArg( 'one', 'two' ) );
51 }
52 }