Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ protected function getMockResults($params = null)
if (null === $params) {
$params = $this->getMockParams();
}
$results = $this->getMockBuilder(\VuFind\Search\Solr\Results::class)
->disableOriginalConstructor()->getMock();
$results = $this->createMock(\VuFind\Search\Solr\Results::class);
$results->method('getParams')->willReturn($params);
return $results;
}
Expand All @@ -99,8 +98,7 @@ protected function getMockParams($query = null)
if (null === $query) {
$query = new \VuFindSearch\Query\Query('foo', 'bar');
}
$params = $this->getMockBuilder(\VuFind\Search\Solr\Params::class)
->disableOriginalConstructor()->getMock();
$params = $this->createMock(\VuFind\Search\Solr\Params::class);
$params->method('getQuery')->willReturn($query);
return $params;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function testSuccessfulTransaction(): void
->willReturn(1);
$this->container->set(CommentsServiceInterface::class, $mockCommentsService);

$driver = $this->getMockBuilder(DefaultRecord::class)->getMock();
$driver = $this->createMock(DefaultRecord::class);
$driver->expects($this->once())
->method('isRatingAllowed')
->willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ protected function getMockParams($query = null)
if (null === $query) {
$query = new \VuFindSearch\Query\Query('foo', 'bar');
}
$params = $this->getMockBuilder(\VuFind\Search\Solr\Params::class)
->disableOriginalConstructor()->getMock();
$params = $this->createMock(\VuFind\Search\Solr\Params::class);
$params->method('getQuery')->willReturn($query);
return $params;
}
Expand All @@ -81,8 +80,7 @@ protected function getMockResults($params = null): Results
if (null === $params) {
$params = $this->getMockParams();
}
$results = $this->getMockBuilder(Results::class)
->disableOriginalConstructor()->getMock();
$results = $this->createMock(Results::class);
$results->method('getParams')->willReturn($params);
return $results;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function testSuccessfulResponse(): void
*/
protected function getMockRequestParams(array $requestParams = []): Params
{
$params = $this->getMockBuilder(Params::class)->getMock();
$params = $this->createMock(Params::class);
$params->method('fromQuery')
->willReturnCallback(
function ($param, $default = null) use ($requestParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ public function testGetSelectableAuthOptions(): void

// Advanced case -- ChoiceAuth's getSelectableAuthOptions returns false.
$pm = $this->getMockPluginManager();
$mockChoice = $this->getMockBuilder(\VuFind\Auth\ChoiceAuth::class)
->disableOriginalConstructor()
->getMock();
$mockChoice = $this->createMock(\VuFind\Auth\ChoiceAuth::class);
$mockChoice->method('getSelectableAuthOptions')->willReturn(false);
$pm->setService('ChoiceAuth2', $mockChoice);
$config = ['Authentication' => ['method' => 'ChoiceAuth2']];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ protected function getMockMultiBackend(array $onlyMethods = []): MockObject&Mult
$onlyMethods[] = 'getConfig';
$onlyMethods[] = 'patronLogin';
$configManager = $this->container->get(\VuFind\Config\ConfigManagerInterface::class);
$ilsAuth = $this->getMockBuilder(\VuFind\Auth\ILSAuthenticator::class)
->disableOriginalConstructor()
->getMock();
$ilsAuth = $this->createMock(\VuFind\Auth\ILSAuthenticator::class);
$driverManager
= $this->getMockBuilder(\VuFind\ILS\Driver\PluginManager::class)
->setConstructorArgs([$this->container])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ public function testEncodingMismatch(): void
*/
public function testImportInLiveMode(): void
{
$mockWriter = $this->getMockBuilder(\VuFind\Solr\Writer::class)
->disableOriginalConstructor()->getMock();
$mockWriter = $this->createMock(\VuFind\Solr\Writer::class);
$mockWriter->expects($this->once())->method('save')->with(
$this->equalTo('Solr'),
$this->callback(
Expand Down Expand Up @@ -284,8 +283,7 @@ function ($doc) {
*/
public function testImportInSmallBatches(): void
{
$mockWriter = $this->getMockBuilder(\VuFind\Solr\Writer::class)
->disableOriginalConstructor()->getMock();
$mockWriter = $this->createMock(\VuFind\Solr\Writer::class);
$mockWriter->expects($this->exactly(3))->method('save')->with(
$this->equalTo('Solr'),
$this->callback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public function testCacheWrite()
->willReturn(null);
$cache->expects($this->once())->method('setItem')
->with($this->matchesRegularExpression('/\d+/'), $this->equalTo($yamlData));
$manager = $this->getMockBuilder(\VuFind\Cache\Manager::class)
->disableOriginalConstructor()
->getMock();
$manager = $this->createMock(\VuFind\Cache\Manager::class);
$manager->expects($this->once())->method('getCache')
->with($this->equalTo('yaml'))
->willReturn($cache);
Expand Down Expand Up @@ -95,9 +93,7 @@ public function testCacheRead()
$cache->expects($this->once())->method('getItem')
->willReturn($yamlData);
$cache->expects($this->never())->method('setItem');
$manager = $this->getMockBuilder(\VuFind\Cache\Manager::class)
->disableOriginalConstructor()
->getMock();
$manager = $this->createMock(\VuFind\Cache\Manager::class);
$manager->expects($this->once())->method('getCache')
->with($this->equalTo('yaml'))
->willReturn($cache);
Expand All @@ -124,9 +120,7 @@ public function testCacheForcedReload()
$cache->expects($this->exactly(2))->method('getItem')
->willReturn($yamlData);
$cache->expects($this->never())->method('setItem');
$manager = $this->getMockBuilder(\VuFind\Cache\Manager::class)
->disableOriginalConstructor()
->getMock();
$manager = $this->createMock(\VuFind\Cache\Manager::class);
$manager->expects($this->exactly(2))->method('getCache')
->with($this->equalTo('yaml'))
->willReturn($cache);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ class BokinfoTest extends \PHPUnit\Framework\TestCase
*/
protected function getMockRequest(): Request
{
$request = $this->getMockBuilder(Request::class)
->disableOriginalConstructor()
->getMock();
$headers = $this->getMockBuilder(Headers::class)
->disableOriginalConstructor()
->getMock();
$request = $this->createMock(Request::class);
$headers = $this->createMock(Headers::class);
$request->expects($this->once())->method('getHeaders')
->willReturn($headers);
$headers->expects($this->once())->method('addHeaderLine')
Expand All @@ -81,9 +77,7 @@ protected function getMockRequest(): Request
*/
protected function getMockResponse(): Response
{
return $this->getMockBuilder(Response::class)
->disableOriginalConstructor()
->getMock();
return $this->createMock(Response::class);
}

/**
Expand All @@ -93,9 +87,7 @@ protected function getMockResponse(): Response
*/
protected function getMockClient(): Client
{
$client = $this->getMockBuilder(Client::class)
->disableOriginalConstructor()
->getMock();
$client = $this->createMock(Client::class);
$client->expects($this->once())->method('setOptions')
->with($this->equalTo(['useragent' => 'VuFind', 'keepalive' => true]));
return $client;
Expand All @@ -108,9 +100,7 @@ protected function getMockClient(): Client
*/
protected function getMockService(): HttpService
{
$service = $this->getMockBuilder(HttpService::class)
->disableOriginalConstructor()
->getMock();
$service = $this->createMock(HttpService::class);
$url1 = 'https://api.bokinfo.se/book/get/9789129697285';
$url2 = 'https://fake-url';
$client1 = $this->getMockClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ protected function getLoader(?string $fixtureFile = null, string $expectedEAN =
{
$loader = new Orb('http://foo', 'fakeuser', 'fakekey');
if ($fixtureFile) {
$mockDownloader = $this->getMockBuilder(CachingDownloader::class)
->disableOriginalConstructor()
->getMock();
$mockDownloader = $this->createMock(CachingDownloader::class);
$fixture = $this->getFixture($fixtureFile);
$mockDownloader->expects($this->once())->method('downloadJson')
->with($this->equalTo("https://fakeuser:fakekey@http://foo/products?eans=$expectedEAN&sort=ean_asc"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ protected function getLoader(
'use_syndetics_cover_image_fallback' => $useSyndeticsCoverImageFallback,
]));
if ($fixtureFile) {
$mockDownloader = $this->getMockBuilder(CachingDownloader::class)
->disableOriginalConstructor()
->getMock();
$mockDownloader = $this->createMock(CachingDownloader::class);
$fixture = $this->getFixture($fixtureFile);
$mockDownloader->expects($this->once())->method('download')
->with($this->equalTo("https://secure.syndetics.com/index.aspx?client=test&isbn=$isbn/index.xml"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public function testBasicPhtmlFunctionality()
'path' => '/path/to/foo.phtml',
'relativePath' => 'to/foo.phtml',
];
$locator = $this->getMockBuilder(\VuFind\Content\PageLocator::class)
->disableOriginalConstructor()
->getMock();
$locator = $this->createMock(\VuFind\Content\PageLocator::class);
$locator->expects($this->once())->method('determineTemplateAndRenderer')
->with($this->equalTo('templates/ContentBlock/TemplateBased/'), $this->equalTo('foo'))
->willReturn($details);
Expand All @@ -83,9 +81,7 @@ public function testBasicPhtmlFunctionalityWithContextOverrides()
'path' => '/path/to/customBasePath/bar.phtml',
'relativePath' => 'customBasePath/bar.phtml',
];
$locator = $this->getMockBuilder(\VuFind\Content\PageLocator::class)
->disableOriginalConstructor()
->getMock();
$locator = $this->createMock(\VuFind\Content\PageLocator::class);
$locator->expects($this->once())->method('determineTemplateAndRenderer')
->with(
$this->equalTo('templates/customBasePath/'),
Expand Down Expand Up @@ -113,9 +109,7 @@ public function testI18nPhtmlFunctionality()
'path' => '/path/to/foo_en.phtml',
'relativePath' => 'to/foo_en.phtml',
];
$locator = $this->getMockBuilder(\VuFind\Content\PageLocator::class)
->disableOriginalConstructor()
->getMock();
$locator = $this->createMock(\VuFind\Content\PageLocator::class);
$locator->expects($this->once())->method('determineTemplateAndRenderer')
->with($this->equalTo('templates/ContentBlock/TemplateBased/'), $this->equalTo('foo'))
->willReturn($details);
Expand All @@ -142,9 +136,7 @@ public function testBasicMarkdownFunctionality()
'path' => $file,
'relativePath' => 'page-locator-test/page4.md',
];
$locator = $this->getMockBuilder(\VuFind\Content\PageLocator::class)
->disableOriginalConstructor()
->getMock();
$locator = $this->createMock(\VuFind\Content\PageLocator::class);
$locator->expects($this->once())->method('determineTemplateAndRenderer')
->with($this->equalTo('templates/ContentBlock/TemplateBased/'), $this->equalTo($file))
->willReturn($details);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public function testRetrieveAndClear()
protected function getMockController(
$url = 'http://localhost/default-url'
): \VuFind\Controller\AbstractBase {
$controller = $this->getMockBuilder(\VuFind\Controller\AbstractBase::class)
->disableOriginalConstructor()->getMock();
$controller = $this->createMock(\VuFind\Controller\AbstractBase::class);
$controller->method('getServerUrl')->willReturn($url);
return $controller;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ public function testGetFundList()
->willReturnCallback(
fn ($method) => $method === 'getFunds' ? ['a', 'b', 'c'] : null
);
$controller = $this->getMockBuilder(\VuFind\Controller\SearchController::class)
->disableOriginalConstructor()->getMock();
$controller = $this->createMock(\VuFind\Controller\SearchController::class);
$controller->expects($this->once())->method('getILS')
->willReturn($catalog);
$newItems = new NewItems(new Config([]));
Expand Down Expand Up @@ -245,8 +244,7 @@ function ($method, $args) {
*/
protected function getMockParams($idLimit = 1024)
{
$params = $this->getMockBuilder(\VuFind\Search\Solr\Params::class)
->disableOriginalConstructor()->getMock();
$params = $this->createMock(\VuFind\Search\Solr\Params::class);
$params->expects($this->once())->method('getLimit')
->willReturn(20);
$params->expects($this->once())->method('getQueryIDLimit')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ public function testNextPrevNavBug()
*/
public function testDisabled()
{
$mockManager
= $this->getMockBuilder(\VuFind\Search\Results\PluginManager::class)
->disableOriginalConstructor()->getMock();
$mockMemory = $this->getMockBuilder(\VuFind\Search\Memory::class)
->disableOriginalConstructor()->getMock();
$mockManager = $this->createMock(\VuFind\Search\Results\PluginManager::class);
$mockMemory = $this->createMock(\VuFind\Search\Memory::class);
$plugin = new ResultScroller(
new Container('test'),
$mockManager,
Expand Down Expand Up @@ -419,10 +416,8 @@ protected function getMockResults(
if (null !== $sort) {
$params->setSort($sort, true);
}
$ss = $this->getMockBuilder(\VuFindSearch\Service::class)
->disableOriginalConstructor()->getMock();
$rl = $this->getMockBuilder(\VuFind\Record\Loader::class)
->disableOriginalConstructor()->getMock();
$ss = $this->createMock(\VuFindSearch\Service::class);
$rl = $this->createMock(\VuFind\Record\Loader::class);
$results = new \VuFindTest\Search\TestHarness\Results(
$params,
$ss,
Expand All @@ -441,11 +436,8 @@ protected function getMockResults(
*/
protected function getMockResultScroller($results): ResultScroller
{
$mockManager = $this->getMockBuilder(
\VuFind\Search\Results\PluginManager::class
)->disableOriginalConstructor()->getMock();
$mockMemory = $this->getMockBuilder(\VuFind\Search\Memory::class)
->disableOriginalConstructor()->getMock();
$mockManager = $this->createMock(\VuFind\Search\Results\PluginManager::class);
$mockMemory = $this->createMock(\VuFind\Search\Memory::class);
$mockMemory->method('getLastSearchId')->willReturn(-123);
$params = [
new Container('test'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function getLoader($config = [], $manager = null, $theme = null, $http
$theme = new ThemeInfo($this->getThemeDir(), $this->testTheme);
}
if (null === $httpService) {
$httpService = $this->getMockBuilder(\VuFindHttp\HttpService::class)->getMock();
$httpService = $this->createMock(\VuFindHttp\HttpService::class);
}
if ($mock) {
$mock = array_unique(array_merge($mock, ['debug']));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function getCoverLoader($config = [], $manager = null, $theme = null,
$theme = new ThemeInfo($this->getThemeDir(), $this->testTheme);
}
if (null === $httpService) {
$httpService = $this->getMockBuilder(\VuFindHttp\HttpService::class)->getMock();
$httpService = $this->createMock(\VuFindHttp\HttpService::class);
}
if ($mock) {
return $this->getMockBuilder(__NAMESPACE__ . '\MockLoader')
Expand Down
8 changes: 2 additions & 6 deletions module/VuFind/tests/unit-tests/src/VuFindTest/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,11 @@ public function testGetBulkExportType(): void
*/
public function testGetBulkUrl(): void
{
$url = $this->getMockBuilder(\Laminas\View\Helper\Url::class)
->disableOriginalConstructor()
->getMock();
$url = $this->createMock(\Laminas\View\Helper\Url::class);
$url->expects($this->once())->method('__invoke')
->with($this->equalTo('cart-doexport'))
->willReturn('/cart/doExport');
$serverUrl = $this->getMockBuilder(\Laminas\View\Helper\ServerUrl::class)
->disableOriginalConstructor()
->getMock();
$serverUrl = $this->createMock(\Laminas\View\Helper\ServerUrl::class);
$serverUrl->expects($this->once())->method('__invoke')
->with($this->equalTo('/cart/doExport'))
->willReturn('http://localhost/cart/doExport');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public function testStrategyListWithNoSettings(): void
*/
public function testStrategyListWithBrowserDetection(): void
{
$mockSettings = $this->getMockBuilder(LocaleSettings::class)
->disableOriginalConstructor()->getMock();
$mockSettings = $this->createMock(LocaleSettings::class);
$mockSettings->expects($this->once())
->method('browserLanguageDetectionEnabled')
->willReturn(true);
Expand All @@ -115,8 +114,7 @@ public function testStrategyListWithBrowserDetection(): void
*/
public function testStrategyListWithoutBrowserDetection(): void
{
$mockSettings = $this->getMockBuilder(LocaleSettings::class)
->disableOriginalConstructor()->getMock();
$mockSettings = $this->createMock(LocaleSettings::class);
$mockSettings->expects($this->once())
->method('browserLanguageDetectionEnabled')
->willReturn(false);
Expand Down
Loading