summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/TestingAccessWrapperTest.php
blob: 7e5b91a1199bc2432082bd188cce9f86b4f996ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

class TestingAccessWrapperTest extends MediaWikiTestCase {
	protected $raw;
	protected $wrapped;

	function setUp() {
		parent::setUp();

		require_once __DIR__ . '/../data/helpers/WellProtectedClass.php';
		$this->raw = new WellProtectedClass();
		$this->wrapped = TestingAccessWrapper::newFromObject( $this->raw );
	}

	function testGetProperty() {
		$this->assertSame( 1, $this->wrapped->property );
	}

	function testSetProperty() {
		$this->wrapped->property = 10;
		$this->assertSame( 10, $this->wrapped->property );
		$this->assertSame( 10, $this->raw->getProperty() );
	}

	function testCallMethod() {
		$this->wrapped->incrementPropertyValue();
		$this->assertSame( 2, $this->wrapped->property );
		$this->assertSame( 2, $this->raw->getProperty() );
	}

	function testCallMethodTwoArgs() {
		$this->assertSame( 'two', $this->wrapped->whatSecondArg( 'one', 'two' ) );
	}
}