summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/diff/DiffOpTest.php
blob: cbe05732dde41d260d79999092c49bb77882782d (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
 * @author Adam Shorland
 *
 * @group Diff
 */
class DiffOpTest extends MediaWikiTestCase {

	/**
	 * @covers DiffOp::getType
	 */
	public function testGetType() {
		$obj = new FakeDiffOp();
		$obj->type = 'foo';
		$this->assertEquals( 'foo', $obj->getType() );
	}

	/**
	 * @covers DiffOp::getOrig
	 */
	public function testGetOrig() {
		$obj = new FakeDiffOp();
		$obj->orig = array( 'foo' );
		$this->assertEquals( array( 'foo' ), $obj->getOrig() );
	}

	/**
	 * @covers DiffOp::getClosing
	 */
	public function testGetClosing() {
		$obj = new FakeDiffOp();
		$obj->closing = array( 'foo' );
		$this->assertEquals( array( 'foo' ), $obj->getClosing() );
	}

	/**
	 * @covers DiffOp::getClosing
	 */
	public function testGetClosingWithParameter() {
		$obj = new FakeDiffOp();
		$obj->closing = array( 'foo', 'bar', 'baz' );
		$this->assertEquals( 'foo', $obj->getClosing( 0 ) );
		$this->assertEquals( 'bar', $obj->getClosing( 1 ) );
		$this->assertEquals( 'baz', $obj->getClosing( 2 ) );
		$this->assertEquals( null, $obj->getClosing( 3 ) );
	}

	/**
	 * @covers DiffOp::norig
	 */
	public function testNorig() {
		$obj = new FakeDiffOp();
		$this->assertEquals( 0, $obj->norig() );
		$obj->orig = array( 'foo' );
		$this->assertEquals( 1, $obj->norig() );
	}

	/**
	 * @covers DiffOp::nclosing
	 */
	public function testNclosing() {
		$obj = new FakeDiffOp();
		$this->assertEquals( 0, $obj->nclosing() );
		$obj->closing = array( 'foo' );
		$this->assertEquals( 1, $obj->nclosing() );
	}

}