wiki.techinc.nl/tests/phpunit/unit/includes/diff/DiffOpTest.php
Thiemo Kreuz 42a03b9752 Make use of DiffOp::norig/nclosing() and update tests
The names of these methods are a little strange, that's probably why
we missed them before.

I tried to update closely related test cases, make use of PHP7 type
hints, as well as yield where it feels it makes sense.

Change-Id: I1cf27138e1e47f713739b6fd53101b9ec7d38fe7
2020-03-25 15:17:17 +00:00

69 lines
1.4 KiB
PHP

<?php
/**
* @author Addshore
*
* @group Diff
*/
class DiffOpTest extends \MediaWikiUnitTestCase {
/**
* @covers DiffOp::getType
*/
public function testGetType() {
$obj = new FakeDiffOp();
$obj->type = 'foo';
$this->assertSame( 'foo', $obj->getType() );
}
/**
* @covers DiffOp::getOrig
*/
public function testGetOrig() {
$obj = new FakeDiffOp();
$obj->orig = [ 'foo' ];
$this->assertSame( [ 'foo' ], $obj->getOrig() );
}
/**
* @covers DiffOp::getClosing
*/
public function testGetClosing() {
$obj = new FakeDiffOp();
$obj->closing = [ 'foo' ];
$this->assertSame( [ 'foo' ], $obj->getClosing() );
}
/**
* @covers DiffOp::getClosing
*/
public function testGetClosingWithParameter() {
$obj = new FakeDiffOp();
$obj->closing = [ 'foo', 'bar', 'baz' ];
$this->assertSame( 'foo', $obj->getClosing( 0 ) );
$this->assertSame( 'bar', $obj->getClosing( 1 ) );
$this->assertSame( 'baz', $obj->getClosing( 2 ) );
$this->assertNull( $obj->getClosing( 3 ) );
}
/**
* @covers DiffOp::norig
*/
public function testNorig() {
$obj = new FakeDiffOp();
$this->assertSame( 0, $obj->norig() );
$obj->orig = [ 'foo' ];
$this->assertSame( 1, $obj->norig() );
}
/**
* @covers DiffOp::nclosing
*/
public function testNclosing() {
$obj = new FakeDiffOp();
$this->assertSame( 0, $obj->nclosing() );
$obj->closing = [ 'foo' ];
$this->assertSame( 1, $obj->nclosing() );
}
}