*/
class ServiceContainerTest extends PHPUnit_Framework_TestCase {
+ use MediaWikiCoversValidator;
+
private function newServiceContainer( $extraArgs = [] ) {
return new ServiceContainer( $extraArgs );
}
$name = 'TestService92834576';
- $this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' );
+ $this->setExpectedException( MediaWiki\Services\NoSuchServiceException::class );
$services->getService( $name );
}
$name = 'TestService92834576';
- $this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' );
+ $this->setExpectedException( MediaWiki\Services\NoSuchServiceException::class );
$services->peekService( $name );
}
return $theService;
} );
- $this->setExpectedException( 'MediaWiki\Services\ServiceAlreadyDefinedException' );
+ $this->setExpectedException( MediaWiki\Services\ServiceAlreadyDefinedException::class );
$services->defineService( $name, function () use ( $theService ) {
return $theService;
];
// loading the same file twice should fail, because
- $this->setExpectedException( 'MediaWiki\Services\ServiceAlreadyDefinedException' );
+ $this->setExpectedException( MediaWiki\Services\ServiceAlreadyDefinedException::class );
$services->loadWiringFiles( $wiringFiles );
}
$theService = new stdClass();
$name = 'TestService92834576';
- $this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' );
+ $this->setExpectedException( MediaWiki\Services\NoSuchServiceException::class );
$services->redefineService( $name, function () use ( $theService ) {
return $theService;
// create the service, so it can no longer be redefined
$services->getService( $name );
- $this->setExpectedException( 'MediaWiki\Services\CannotReplaceActiveServiceException' );
+ $this->setExpectedException( MediaWiki\Services\CannotReplaceActiveServiceException::class );
$services->redefineService( $name, function () use ( $theService ) {
return $theService;
public function testDisableService() {
$services = $this->newServiceContainer( [ 'Foo' ] );
- $destructible = $this->getMockBuilder( 'MediaWiki\Services\DestructibleService' )
+ $destructible = $this->getMockBuilder( MediaWiki\Services\DestructibleService::class )
->getMock();
$destructible->expects( $this->once() )
->method( 'destroy' );
$this->assertContains( 'Bar', $services->getServiceNames() );
$this->assertContains( 'Qux', $services->getServiceNames() );
- $this->setExpectedException( 'MediaWiki\Services\ServiceDisabledException' );
+ $this->setExpectedException( MediaWiki\Services\ServiceDisabledException::class );
$services->getService( 'Qux' );
}
$theService = new stdClass();
$name = 'TestService92834576';
- $this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' );
+ $this->setExpectedException( MediaWiki\Services\NoSuchServiceException::class );
$services->redefineService( $name, function () use ( $theService ) {
return $theService;
public function testDestroy() {
$services = $this->newServiceContainer();
- $destructible = $this->getMockBuilder( 'MediaWiki\Services\DestructibleService' )
+ $destructible = $this->getMockBuilder( MediaWiki\Services\DestructibleService::class )
->getMock();
$destructible->expects( $this->once() )
->method( 'destroy' );
// destroy the container
$services->destroy();
- $this->setExpectedException( 'MediaWiki\Services\ContainerDisabledException' );
+ $this->setExpectedException( MediaWiki\Services\ContainerDisabledException::class );
$services->getService( 'Bar' );
}