assertEquals( null, … ) still succeeds when the actual value is 0, false, an empty string, even an empty array. All these should be reported as a failure, I would argue. Note this patch previously also touched assertSame( null ). I reverted these. The only benefit would have been consistency within this codebase, but there is no strict reason to prefer one over the other. assertNull() and assertSame( null ) are functionally identical. Change-Id: I92102e833a8bc6af90b9516826abf111e2b79aac
68 lines
1.4 KiB
PHP
68 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->assertEquals( 'foo', $obj->getType() );
|
|
}
|
|
|
|
/**
|
|
* @covers DiffOp::getOrig
|
|
*/
|
|
public function testGetOrig() {
|
|
$obj = new FakeDiffOp();
|
|
$obj->orig = [ 'foo' ];
|
|
$this->assertEquals( [ 'foo' ], $obj->getOrig() );
|
|
}
|
|
|
|
/**
|
|
* @covers DiffOp::getClosing
|
|
*/
|
|
public function testGetClosing() {
|
|
$obj = new FakeDiffOp();
|
|
$obj->closing = [ 'foo' ];
|
|
$this->assertEquals( [ 'foo' ], $obj->getClosing() );
|
|
}
|
|
|
|
/**
|
|
* @covers DiffOp::getClosing
|
|
*/
|
|
public function testGetClosingWithParameter() {
|
|
$obj = new FakeDiffOp();
|
|
$obj->closing = [ 'foo', 'bar', 'baz' ];
|
|
$this->assertEquals( 'foo', $obj->getClosing( 0 ) );
|
|
$this->assertEquals( 'bar', $obj->getClosing( 1 ) );
|
|
$this->assertEquals( '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->assertEquals( 1, $obj->norig() );
|
|
}
|
|
|
|
/**
|
|
* @covers DiffOp::nclosing
|
|
*/
|
|
public function testNclosing() {
|
|
$obj = new FakeDiffOp();
|
|
$this->assertSame( 0, $obj->nclosing() );
|
|
$obj->closing = [ 'foo' ];
|
|
$this->assertEquals( 1, $obj->nclosing() );
|
|
}
|
|
|
|
}
|