X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FTitleArrayFromResultTest.php;h=7c2973f93f2c94eee14e98827fa4a236e8d3baf4;hb=15c27d356b5e6760024ac0653279a76d94d78b1f;hp=aad435e77713762904150ad96f25ce2e37db0d0c;hpb=e047732be4f78b1f803173db4b10fcde45225e6d;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/TitleArrayFromResultTest.php b/tests/phpunit/includes/TitleArrayFromResultTest.php index aad435e777..32c757101a 100644 --- a/tests/phpunit/includes/TitleArrayFromResultTest.php +++ b/tests/phpunit/includes/TitleArrayFromResultTest.php @@ -1,13 +1,15 @@ getMockBuilder( 'ResultWrapper' ) + $resultWrapper = $this->getMockBuilder( Wikimedia\Rdbms\ResultWrapper::class ) ->disableOriginalConstructor(); $resultWrapper = $resultWrapper->getMock(); @@ -28,10 +30,6 @@ class TitleArrayFromResultTest extends PHPUnit_Framework_TestCase { return $row; } - private function getTitleArrayFromResult( $resultWrapper ) { - return new TitleArrayFromResult( $resultWrapper ); - } - /** * @covers TitleArrayFromResult::__construct */ @@ -39,7 +37,7 @@ class TitleArrayFromResultTest extends PHPUnit_Framework_TestCase { $row = false; $resultWrapper = $this->getMockResultWrapper( $row ); - $object = $this->getTitleArrayFromResult( $resultWrapper ); + $object = new TitleArrayFromResult( $resultWrapper ); $this->assertEquals( $resultWrapper, $object->res ); $this->assertSame( 0, $object->key ); @@ -55,21 +53,21 @@ class TitleArrayFromResultTest extends PHPUnit_Framework_TestCase { $row = $this->getRowWithTitle( $namespace, $title ); $resultWrapper = $this->getMockResultWrapper( $row ); - $object = $this->getTitleArrayFromResult( $resultWrapper ); + $object = new TitleArrayFromResult( $resultWrapper ); $this->assertEquals( $resultWrapper, $object->res ); $this->assertSame( 0, $object->key ); - $this->assertInstanceOf( 'Title', $object->current ); + $this->assertInstanceOf( Title::class, $object->current ); $this->assertEquals( $namespace, $object->current->mNamespace ); $this->assertEquals( $title, $object->current->mTextform ); } public static function provideNumberOfRows() { - return array( - array( 0 ), - array( 1 ), - array( 122 ), - ); + return [ + [ 0 ], + [ 1 ], + [ 122 ], + ]; } /** @@ -77,7 +75,7 @@ class TitleArrayFromResultTest extends PHPUnit_Framework_TestCase { * @covers TitleArrayFromResult::count */ public function testCountWithVaryingValues( $numRows ) { - $object = $this->getTitleArrayFromResult( $this->getMockResultWrapper( + $object = new TitleArrayFromResult( $this->getMockResultWrapper( $this->getRowWithTitle(), $numRows ) ); @@ -91,17 +89,17 @@ class TitleArrayFromResultTest extends PHPUnit_Framework_TestCase { $namespace = 0; $title = 'foo'; $row = $this->getRowWithTitle( $namespace, $title ); - $object = $this->getTitleArrayFromResult( $this->getMockResultWrapper( $row ) ); - $this->assertInstanceOf( 'Title', $object->current() ); + $object = new TitleArrayFromResult( $this->getMockResultWrapper( $row ) ); + $this->assertInstanceOf( Title::class, $object->current() ); $this->assertEquals( $namespace, $object->current->mNamespace ); $this->assertEquals( $title, $object->current->mTextform ); } public function provideTestValid() { - return array( - array( $this->getRowWithTitle(), true ), - array( false, false ), - ); + return [ + [ $this->getRowWithTitle(), true ], + [ false, false ], + ]; } /** @@ -109,7 +107,7 @@ class TitleArrayFromResultTest extends PHPUnit_Framework_TestCase { * @covers TitleArrayFromResult::valid */ public function testValid( $input, $expected ) { - $object = $this->getTitleArrayFromResult( $this->getMockResultWrapper( $input ) ); + $object = new TitleArrayFromResult( $this->getMockResultWrapper( $input ) ); $this->assertEquals( $expected, $object->valid() ); }