Tests: Replaced setMethods as it is deprecated

This commit is contained in:
Igor Scheller 2019-11-06 12:29:58 +01:00
parent 109f112131
commit 867d720f15
23 changed files with 41 additions and 41 deletions

View File

@ -117,8 +117,8 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
LogEntry::query()->truncate();
$logger = $this->getLogger();
$mock = $this->getMockBuilder('someDataProvider')
->setMethods(['__toString'])
$mock = $this->getMockBuilder(stdClass::class)
->addMethods(['__toString'])
->getMock();
$mock->expects($this->atLeastOnce())

View File

@ -113,7 +113,7 @@ class ApplicationTest extends TestCase
$mockClassName = $this->getMockClass(ServiceProvider::class);
$serviceProvider = $this->getMockBuilder($mockClassName)
->setConstructorArgs([$app])
->setMethods(['register'])
->onlyMethods(['register'])
->getMock();
$serviceProvider->expects($this->once())
@ -132,7 +132,7 @@ class ApplicationTest extends TestCase
{
/** @var Application|MockObject $app */
$app = $this->getMockBuilder(Application::class)
->setMethods(['register'])
->onlyMethods(['register'])
->getMock();
$serviceProvider = $this->mockServiceProvider($app, ['boot']);
@ -175,7 +175,7 @@ class ApplicationTest extends TestCase
{
$serviceProvider = $this->getMockBuilder(ServiceProvider::class)
->setConstructorArgs([$app])
->setMethods($methods)
->onlyMethods($methods)
->getMockForAbstractClass();
return $serviceProvider;

View File

@ -24,7 +24,7 @@ class MigrateTest extends TestCase
{
/** @var Application|MockObject $app */
$app = $this->getMockBuilder(Application::class)
->setMethods(['instance'])
->onlyMethods(['instance'])
->getMock();
/** @var SchemaBuilder|MockObject $builder */
$builder = $this->getMockBuilder(SchemaBuilder::class)
@ -33,7 +33,7 @@ class MigrateTest extends TestCase
/** @var Migrate|MockObject $migration */
$migration = $this->getMockBuilder(Migrate::class)
->setConstructorArgs([$builder, $app])
->setMethods(['initMigration', 'getMigrationFiles', 'getMigrated', 'migrate', 'setMigrated'])
->onlyMethods(['initMigration', 'getMigrationFiles', 'getMigrated', 'migrate', 'setMigrated'])
->getMock();
$migration->expects($this->atLeastOnce())

View File

@ -33,7 +33,7 @@ class HandlerTest extends TestCase
{
/** @var Handler|MockObject $handler */
$handler = $this->getMockBuilder(Handler::class)
->setMethods(['exceptionHandler'])
->onlyMethods(['exceptionHandler'])
->getMock();
$handler->expects($this->once())
@ -65,7 +65,7 @@ class HandlerTest extends TestCase
/** @var Handler|MockObject $handler */
$handler = $this->getMockBuilder(Handler::class)
->setMethods(['terminateApplicationImmediately'])
->onlyMethods(['terminateApplicationImmediately'])
->getMock();
$handler->expects($this->once())
->method('terminateApplicationImmediately');

View File

@ -128,7 +128,7 @@ class AuthenticatorTest extends ServiceProviderTest
/** @var Authenticator|MockObject $auth */
$auth = $this->getMockBuilder(Authenticator::class)
->setConstructorArgs([$request, $session, $userRepository])
->setMethods(['getPermissionsByGroup', 'getPermissionsByUser', 'user'])
->onlyMethods(['getPermissionsByGroup', 'getPermissionsByUser', 'user'])
->getMock();
$auth->expects($this->exactly(1))
->method('getPermissionsByGroup')
@ -203,7 +203,7 @@ class AuthenticatorTest extends ServiceProviderTest
/** @var Authenticator|MockObject $auth */
$auth = $this->getMockBuilder(Authenticator::class)
->disableOriginalConstructor()
->setMethods(['setPassword'])
->onlyMethods(['setPassword'])
->getMock();
$auth->expects($this->once())

View File

@ -26,7 +26,7 @@ class TranslatorTest extends ServiceProviderTest
/** @var callable|MockObject $localeChange */
$localeChange = $this->getMockBuilder(stdClass::class)
->setMethods(['__invoke'])
->addMethods(['__invoke'])
->getMock();
$localeChange->expects($this->exactly(2))
->method('__invoke')
@ -56,7 +56,7 @@ class TranslatorTest extends ServiceProviderTest
/** @var Translator|MockObject $translator */
$translator = $this->getMockBuilder(Translator::class)
->setConstructorArgs(['de_DE', 'en_US', function () { }, ['de_DE' => 'Deutsch']])
->setMethods(['translateText'])
->onlyMethods(['translateText'])
->getMock();
$translator->expects($this->exactly(2))
->method('translateText')
@ -78,7 +78,7 @@ class TranslatorTest extends ServiceProviderTest
/** @var Translator|MockObject $translator */
$translator = $this->getMockBuilder(Translator::class)
->setConstructorArgs(['de_DE', 'en_US', function () { }, ['de_DE' => 'Deutsch']])
->setMethods(['translateText'])
->onlyMethods(['translateText'])
->getMock();
$translator->expects($this->once())
->method('translateText')
@ -100,7 +100,7 @@ class TranslatorTest extends ServiceProviderTest
$gtt = $this->createMock(GettextTranslator::class);
/** @var callable|MockObject $getTranslator */
$getTranslator = $this->getMockBuilder(stdClass::class)
->setMethods(['__invoke'])
->addMethods(['__invoke'])
->getMock();
$getTranslator->expects($this->exactly(5))
->method('__invoke')

View File

@ -59,7 +59,7 @@ class RequestServiceProviderTest extends ServiceProviderTest
/** @var ServiceProvider|MockObject $serviceProvider */
$serviceProvider = $this->getMockBuilder(RequestServiceProvider::class)
->setConstructorArgs([$app])
->setMethods(['setTrustedProxies'])
->onlyMethods(['setTrustedProxies'])
->getMock();
$serviceProvider->expects($this->once())
->method('setTrustedProxies')

View File

@ -93,7 +93,7 @@ class RequestTest extends TestCase
/** @var Request|MockObject $request */
$request = $this
->getMockBuilder(Request::class)
->setMethods(['getPathInfo'])
->onlyMethods(['getPathInfo'])
->getMock();
$request
@ -116,7 +116,7 @@ class RequestTest extends TestCase
/** @var Request|MockObject $request */
$request = $this
->getMockBuilder(Request::class)
->setMethods(['getUri'])
->onlyMethods(['getUri'])
->getMock();
$request
@ -139,7 +139,7 @@ class RequestTest extends TestCase
/** @var Request|MockObject $request */
$request = $this
->getMockBuilder(Request::class)
->setMethods(['getQueryString', 'path'])
->onlyMethods(['getQueryString', 'path'])
->getMock();
$request->expects($this->exactly(2))

View File

@ -36,7 +36,7 @@ class SessionServiceProviderTest extends ServiceProviderTest
/** @var SessionServiceProvider|MockObject $serviceProvider */
$serviceProvider = $this->getMockBuilder(SessionServiceProvider::class)
->setConstructorArgs([$app])
->setMethods(['isCli'])
->onlyMethods(['isCli'])
->getMock();
/** @var Config|MockObject $config */
@ -175,7 +175,7 @@ class SessionServiceProviderTest extends ServiceProviderTest
$sessionStorage = $this->getMockForAbstractClass(StorageInterface::class);
return $this->getMockBuilder(Session::class)
->setConstructorArgs([$sessionStorage])
->setMethods(['start', 'has', 'set'])
->onlyMethods(['start', 'has', 'set'])
->getMock();
}
@ -185,7 +185,7 @@ class SessionServiceProviderTest extends ServiceProviderTest
private function getRequestMock()
{
return $this->getMockBuilder(Request::class)
->setMethods(['setSession'])
->onlyMethods(['setSession'])
->getMock();
}
}

View File

@ -44,7 +44,7 @@ class LogTransportTest extends TestCase
/** @var LogTransport|MockObject $transport */
$transport = $this->getMockBuilder(LogTransport::class)
->setConstructorArgs(['logger' => $logger])
->setMethods(['allRecipients'])
->onlyMethods(['allRecipients'])
->getMock();
$transport->expects($this->exactly(2))
->method('allRecipients')

View File

@ -79,7 +79,7 @@ class TransportTest extends TestCase
$message = $this->createMock(SimpleMessage::class);
/** @var TransportImplementation|MockObject $transport */
$transport = $this->getMockBuilder(TransportImplementation::class)
->setMethods(['allRecipients'])
->onlyMethods(['allRecipients'])
->getMock();
$transport->expects($this->once())
->method('allRecipients')

View File

@ -132,7 +132,7 @@ class CallableHandlerTest extends TestCase
$response = $this->createMock(Response::class);
/** @var callable|MockObject $callable */
$callable = $this->getMockBuilder(stdClass::class)
->setMethods(['__invoke'])
->addMethods(['__invoke'])
->getMock();
return [$request, $response, $callable, $handler];
}

View File

@ -49,7 +49,7 @@ class DispatcherTest extends TestCase
/** @var Dispatcher|MockObject $dispatcher */
$dispatcher = $this->getMockBuilder(Dispatcher::class)
->setMethods(['handle'])
->onlyMethods(['handle'])
->getMock();
$dispatcher->expects($this->once())
@ -158,7 +158,7 @@ class DispatcherTest extends TestCase
/** @var Dispatcher|MockObject $dispatcher */
$dispatcher = $this->getMockBuilder(Dispatcher::class)
->setConstructorArgs([[MiddlewareInterface::class, MiddlewareInterface::class]])
->setMethods(['resolveMiddleware'])
->onlyMethods(['resolveMiddleware'])
->getMock();
$dispatcher->expects($this->exactly(2))

View File

@ -141,7 +141,7 @@ class ErrorHandlerTest extends TestCase
/** @var ErrorHandler|MockObject $errorHandler */
$errorHandler = $this->getMockBuilder(ErrorHandler::class)
->disableOriginalConstructor()
->setMethods(['createResponse'])
->onlyMethods(['createResponse'])
->getMock();
$errorHandler->expects($this->once())

View File

@ -29,7 +29,7 @@ class LegacyMiddlewareTest extends TestCase
/** @var LegacyMiddleware|MockObject $middleware */
$middleware = $this->getMockBuilder(LegacyMiddleware::class)
->setConstructorArgs([$container, $auth])
->setMethods(['loadPage', 'renderPage'])
->onlyMethods(['loadPage', 'renderPage'])
->getMock();
/** @var Request|MockObject $defaultRequest */
$defaultRequest = $this->createMock(Request::class);

View File

@ -58,7 +58,7 @@ class RequestHandlerTest extends TestCase
/** @var RequestHandler|MockObject $middleware */
$middleware = $this->getMockBuilder(RequestHandler::class)
->setConstructorArgs([$container])
->setMethods(['resolveRequestHandler'])
->onlyMethods(['resolveRequestHandler'])
->getMock();
$middleware->expects($this->exactly(3))
->method('resolveRequestHandler')
@ -110,7 +110,7 @@ class RequestHandlerTest extends TestCase
/** @var RequestHandler|MockObject $middleware */
$middleware = $this->getMockBuilder(RequestHandler::class)
->setConstructorArgs([$container])
->setMethods(['resolveMiddleware'])
->onlyMethods(['resolveMiddleware'])
->getMock();
$middleware->expects($this->once())
->method('resolveMiddleware')
@ -174,7 +174,7 @@ class RequestHandlerTest extends TestCase
/** @var RequestHandler|MockObject $middleware */
$middleware = $this->getMockBuilder(RequestHandler::class)
->setConstructorArgs([$container])
->setMethods(['resolveRequestHandler'])
->onlyMethods(['resolveRequestHandler'])
->getMock();
$middleware->expects($this->exactly(2))

View File

@ -62,7 +62,7 @@ class RouteDispatcherServiceProviderTest extends ServiceProviderTest
/** @var RouteDispatcherServiceProvider|MockObject $serviceProvider */
$serviceProvider = $this->getMockBuilder(RouteDispatcherServiceProvider::class)
->setConstructorArgs([$app])
->setMethods(['generateRouting'])
->onlyMethods(['generateRouting'])
->getMock();
$serviceProvider->expects($this->once())

View File

@ -18,7 +18,7 @@ class SendResponseHandlerTest extends TestCase
{
/** @var SendResponseHandler|MockObject $middleware */
$middleware = $this->getMockBuilder(SendResponseHandler::class)
->setMethods(['headersSent', 'sendHeader'])
->onlyMethods(['headersSent', 'sendHeader'])
->getMock();
/** @var ServerRequestInterface|MockObject $request */
$request = $this->getMockForAbstractClass(ServerRequestInterface::class);

View File

@ -48,7 +48,7 @@ class SessionHandlerTest extends TestCase
/** @var SessionHandler|MockObject $middleware */
$middleware = $this->getMockBuilder(SessionHandler::class)
->setConstructorArgs([$sessionStorage, ['/foo']])
->setMethods(['destroyNative'])
->onlyMethods(['destroyNative'])
->getMock();
$middleware->expects($this->once())

View File

@ -34,7 +34,7 @@ class VerifyCsrfTokenTest extends TestCase
/** @var VerifyCsrfToken|MockObject $middleware */
$middleware = $this->getMockBuilder(VerifyCsrfToken::class)
->disableOriginalConstructor()
->setMethods(['tokensMatch'])
->onlyMethods(['tokensMatch'])
->getMock();
$middleware->expects($this->exactly(2))
@ -74,7 +74,7 @@ class VerifyCsrfTokenTest extends TestCase
/** @var VerifyCsrfToken|MockObject $middleware */
$middleware = $this->getMockBuilder(VerifyCsrfToken::class)
->setConstructorArgs([$session])
->setMethods(['isReading'])
->onlyMethods(['isReading'])
->getMock();
$middleware->expects($this->atLeastOnce())

View File

@ -31,7 +31,7 @@ class CsrfTest extends ExtensionTest
/** @var Csrf|MockObject $extension */
$extension = $this->getMockBuilder(Csrf::class)
->disableOriginalConstructor()
->setMethods(['getCsrfToken'])
->onlyMethods(['getCsrfToken'])
->getMock();
$extension->expects($this->once())

View File

@ -48,7 +48,7 @@ class TwigServiceProviderTest extends ServiceProviderTest
/** @var TwigServiceProvider|MockObject $serviceProvider */
$serviceProvider = $this->getMockBuilder(TwigServiceProvider::class)
->setConstructorArgs([$app])
->setMethods(['registerTwigEngine'])
->onlyMethods(['registerTwigEngine'])
->getMock();
$serviceProvider->expects($this->once())
->method('registerTwigEngine');
@ -103,7 +103,7 @@ class TwigServiceProviderTest extends ServiceProviderTest
$config = $this->createMock(Config::class);
/** @var TwigCore|MockObject $twigCore */
$twigCore = $this->getMockBuilder(stdClass::class)
->setMethods(['setTimezone'])
->addMethods(['setTimezone'])
->getMock();
$app = $this->getApp(['make', 'instance', 'tag', 'get']);

View File

@ -14,7 +14,7 @@ abstract class ServiceProviderTest extends TestCase
protected function getApp($methods = ['make', 'instance'])
{
return $this->getMockBuilder(Application::class)
->setMethods($methods)
->onlyMethods($methods)
->getMock();
}
}