diff options
7 files changed, 48 insertions, 100 deletions
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index 9414bebd0dd..94e099f523e 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php @@ -30,9 +30,6 @@ use OC\KnownUser\KnownUserService; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCA\DAV\Connector\Sabre\Principal; -use OCA\DAV\Events\CalendarCreatedEvent; -use OCA\DAV\Events\CalendarDeletedEvent; -use OCA\DAV\Events\CalendarObjectCreatedEvent; use OCP\App\IAppManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; @@ -65,9 +62,9 @@ abstract class AbstractCalDavBackend extends TestCase { protected $userManager; /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */ protected $groupManager; - /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ - protected $dispatcher; /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ + protected $dispatcher; + /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $legacyDispatcher; /** @var ISecureRandom */ @@ -146,11 +143,10 @@ abstract class AbstractCalDavBackend extends TestCase { private function cleanupForPrincipal($principal): void { $calendars = $this->backend->getCalendarsForUser($principal); - $this->legacyDispatcher->expects(self::exactly(count($calendars))) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarDeletedEvent; - })); + $this->dispatcher->expects(self::any()) + ->method('dispatchTyped'); + $this->legacyDispatcher->expects(self::any()) + ->method('dispatch'); foreach ($calendars as $calendar) { $this->backend->deleteCalendar($calendar['id'], true); } @@ -161,11 +157,8 @@ abstract class AbstractCalDavBackend extends TestCase { } protected function createTestCalendar() { - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarCreatedEvent; - })); + $this->dispatcher->expects(self::any()) + ->method('dispatchTyped'); $this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', [ '{http://apple.com/ns/ical/}calendar-color' => '#1C4587FF' @@ -220,11 +213,8 @@ END:VCALENDAR EOD; $uri0 = $this->getUniqueID('event'); - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarObjectCreatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->createCalendarObject($calendarId, $uri0, $calData); diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 168269bb16e..13066a5fa9b 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -35,10 +35,7 @@ use DateTime; use DateTimeZone; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Calendar; -use OCA\DAV\Events\CalendarCreatedEvent; use OCA\DAV\Events\CalendarDeletedEvent; -use OCA\DAV\Events\CalendarObjectCreatedEvent; -use OCA\DAV\Events\CalendarUpdatedEvent; use OCP\IConfig; use OCP\IL10N; use Sabre\DAV\Exception\NotFound; @@ -62,11 +59,8 @@ class CalDavBackendTest extends AbstractCalDavBackend { '{DAV:}displayname' => 'Unit test', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar used for unit testing' ]); - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarUpdatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->updateCalendar($calendarId, $patch); $patch->commit(); $this->assertEquals(1, $this->backend->getCalendarsForUserCount(self::UNIT_TEST_USER)); @@ -77,11 +71,8 @@ class CalDavBackendTest extends AbstractCalDavBackend { $this->assertEquals('User\'s displayname', $calendars[0]['{http://nextcloud.com/ns}owner-displayname']); // delete the address book - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarDeletedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->deleteCalendar($calendars[0]['id'], true); $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER); self::assertEmpty($calendars); @@ -190,11 +181,8 @@ END:VEVENT END:VCALENDAR EOD; - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarObjectCreatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->createCalendarObject($calendarId, $uri, $calData); /** @var IACL $child */ @@ -238,11 +226,8 @@ END:VEVENT END:VCALENDAR EOD; - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarObjectCreatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->createCalendarObject($calendarId, $uri, $calData); // get all the cards @@ -278,21 +263,15 @@ DTEND;VALUE=DATE-TIME:20130912T140000Z END:VEVENT END:VCALENDAR EOD; - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarUpdatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->updateCalendarObject($calendarId, $uri, $calData); $calendarObject = $this->backend->getCalendarObject($calendarId, $uri); $this->assertEquals($calData, $calendarObject['calendardata']); // delete the card - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarDeletedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->deleteCalendarObject($calendarId, $uri); $calendarObjects = $this->backend->getCalendarObjects($calendarId); $this->assertCount(0, $calendarObjects); @@ -385,25 +364,16 @@ END:VCALENDAR EOD; $uri0 = static::getUniqueID('card'); - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarObjectCreatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->createCalendarObject($calendarId, $uri0, $calData[0]); $uri1 = static::getUniqueID('card'); - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarObjectCreatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->createCalendarObject($calendarId, $uri1, $calData[1]); $uri2 = static::getUniqueID('card'); - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarObjectCreatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->createCalendarObject($calendarId, $uri2, $calData[2]); // get all the cards @@ -430,23 +400,14 @@ EOD; $this->assertEquals($calData[2], $calendarObjects[1]['calendardata']); // delete the card - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarDeletedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->deleteCalendarObject($calendarId, $uri0); - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarDeletedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->deleteCalendarObject($calendarId, $uri1); - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarDeletedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->deleteCalendarObject($calendarId, $uri2); $calendarObjects = $this->backend->getCalendarObjects($calendarId); $this->assertCount(0, $calendarObjects); @@ -529,11 +490,8 @@ EOD; } public function testPublications() { - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarCreatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', []); diff --git a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php index 05442455cb7..d6ceefa4268 100644 --- a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php +++ b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php @@ -89,7 +89,7 @@ class CoordinatorTest extends TestCase { ->with(\OCA\Settings\AppInfo\Application::class) ->willThrowException(new QueryException("")); $this->logger->expects($this->once()) - ->method('logException'); + ->method('error'); $this->coordinator->bootApp($appId); } diff --git a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php index f97ac92e887..067e9a09673 100644 --- a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php +++ b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php @@ -61,7 +61,7 @@ class RegistrationContextTest extends TestCase { ->method('registerCapability') ->with($name); $this->logger->expects($this->never()) - ->method('logException'); + ->method('error'); $this->context->for('myapp')->registerCapability($name); $this->context->delegateCapabilityRegistrations([ @@ -77,7 +77,7 @@ class RegistrationContextTest extends TestCase { ->method('addServiceListener') ->with($event, $service, 0); $this->logger->expects($this->never()) - ->method('logException'); + ->method('error'); $this->context->for('myapp')->registerEventListener($event, $service); $this->context->delegateEventListenerRegistrations($dispatcher); @@ -99,7 +99,7 @@ class RegistrationContextTest extends TestCase { ->method('registerService') ->with($service, $factory, $shared); $this->logger->expects($this->never()) - ->method('logException'); + ->method('error'); $this->context->for('myapp')->registerService($service, $factory, $shared); $this->context->delegateContainerRegistrations([ @@ -118,7 +118,7 @@ class RegistrationContextTest extends TestCase { ->method('registerAlias') ->with($alias, $target); $this->logger->expects($this->never()) - ->method('logException'); + ->method('error'); $this->context->for('myapp')->registerServiceAlias($alias, $target); $this->context->delegateContainerRegistrations([ @@ -137,7 +137,7 @@ class RegistrationContextTest extends TestCase { ->method('registerParameter') ->with($name, $value); $this->logger->expects($this->never()) - ->method('logException'); + ->method('error'); $this->context->for('myapp')->registerParameter($name, $value); $this->context->delegateContainerRegistrations([ @@ -155,7 +155,7 @@ class RegistrationContextTest extends TestCase { ->method('registerMiddleware') ->with($name); $this->logger->expects($this->never()) - ->method('logException'); + ->method('error'); $this->context->for('myapp')->registerMiddleware($name); $this->context->delegateMiddlewareRegistrations([ diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 076f6588d94..8f55f90d377 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -506,7 +506,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { ->willReturn('http://localhost/nextcloud/index.php/login?redirect_url=nextcloud/index.php/apps/specialapp'); $this->logger ->expects($this->once()) - ->method('logException'); + ->method('debug'); $response = $this->middleware->afterException( $this->controller, 'test', @@ -576,7 +576,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->middleware = $this->getMiddleware(false, false, false); $this->logger ->expects($this->once()) - ->method('logException'); + ->method('debug'); $response = $this->middleware->afterException( $this->controller, 'test', diff --git a/tests/lib/CapabilitiesManagerTest.php b/tests/lib/CapabilitiesManagerTest.php index 4909272c4a8..ec07f3dfa36 100644 --- a/tests/lib/CapabilitiesManagerTest.php +++ b/tests/lib/CapabilitiesManagerTest.php @@ -149,7 +149,7 @@ class CapabilitiesManagerTest extends TestCase { }); $this->logger->expects($this->once()) - ->method('logException'); + ->method('error'); $res = $this->manager->getCapabilities(); diff --git a/tests/lib/Collaboration/Resources/ProviderManagerTest.php b/tests/lib/Collaboration/Resources/ProviderManagerTest.php index 19a34962a56..01e45de9fdf 100644 --- a/tests/lib/Collaboration/Resources/ProviderManagerTest.php +++ b/tests/lib/Collaboration/Resources/ProviderManagerTest.php @@ -82,7 +82,7 @@ class ProviderManagerTest extends TestCase { ->willThrowException(new QueryException('A meaningful error message')); $this->logger->expects($this->once()) - ->method('logException'); + ->method('error'); $this->providerManager->registerResourceProvider('InvalidResourceProvider'); $resourceProviders = $this->providerManager->getResourceProviders(); @@ -101,7 +101,7 @@ class ProviderManagerTest extends TestCase { ->willReturn($this->createMock(ResourceProvider::class)); $this->logger->expects($this->once()) - ->method('logException'); + ->method('error'); $this->providerManager->registerResourceProvider('InvalidResourceProvider'); $this->providerManager->registerResourceProvider(ResourceProvider::class); |