Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <[email protected]>
  • Loading branch information
rullzer committed Nov 27, 2019
commit 3a7cf40aaa678bea1df143d2982d603b7a334eec
2 changes: 1 addition & 1 deletion apps/admin_audit/tests/Actions/SecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SecurityTest extends TestCase {
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject */
private $user;

public function setUp(): void {
protected function setUp(): void {
parent::setUp();

$this->logger = $this->createMock(ILogger::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CommentersSorterTest extends TestCase {
/** @var CommentersSorter */
protected $sorter;

public function setUp(): void {
protected function setUp(): void {
parent::setUp();

$this->commentsManager = $this->createMock(ICommentsManager::class);
Expand Down
2 changes: 1 addition & 1 deletion apps/comments/tests/Unit/JSSettingsHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class JSSettingsHelperTest extends TestCase {
/** @var JSSettingsHelper */
protected $helper;

public function setUp(): void {
protected function setUp(): void {
parent::setUp();

$this->c = $this->createMock(IServerContainer::class);
Expand Down
30 changes: 15 additions & 15 deletions apps/comments/tests/Unit/Notification/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ public function testPrepareSuccessDeletedUser() {
$this->notifier->prepare($this->notification, $this->lc);
}

/**
* @expectedException \InvalidArgumentException
*/

public function testPrepareDifferentApp() {
$this->expectException(\InvalidArgumentException::class);

$this->folder
->expects($this->never())
->method('getById');
Expand Down Expand Up @@ -376,10 +376,10 @@ public function testPrepareDifferentApp() {
$this->notifier->prepare($this->notification, $this->lc);
}

/**
* @expectedException \InvalidArgumentException
*/

public function testPrepareNotFound() {
$this->expectException(\InvalidArgumentException::class);

$this->folder
->expects($this->never())
->method('getById');
Expand Down Expand Up @@ -414,10 +414,10 @@ public function testPrepareNotFound() {
$this->notifier->prepare($this->notification, $this->lc);
}

/**
* @expectedException \InvalidArgumentException
*/

public function testPrepareDifferentSubject() {
$this->expectException(\InvalidArgumentException::class);

$displayName = 'Huraga';

/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
Expand Down Expand Up @@ -477,10 +477,10 @@ public function testPrepareDifferentSubject() {
$this->notifier->prepare($this->notification, $this->lc);
}

/**
* @expectedException \InvalidArgumentException
*/

public function testPrepareNotFiles() {
$this->expectException(\InvalidArgumentException::class);

$displayName = 'Huraga';

/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
Expand Down Expand Up @@ -541,10 +541,10 @@ public function testPrepareNotFiles() {
$this->notifier->prepare($this->notification, $this->lc);
}

/**
* @expectedException \OCP\Notification\AlreadyProcessedException
*/

public function testPrepareUnresolvableFileID() {
$this->expectException(\OCP\Notification\AlreadyProcessedException::class);

$displayName = 'Huraga';

/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
Expand Down
4 changes: 1 addition & 3 deletions apps/dav/lib/CalDAV/CachedSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ public function getOwner() {
return parent::getOwner();
}

/**
*
*/

public function delete() {
$this->caldavBackend->deleteSubscription($this->calendarInfo['id']);
}
Expand Down
4 changes: 1 addition & 3 deletions apps/dav/lib/CalDAV/CalendarHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ function calendarSearch(array $filters, $limit=null, $offset=null) {
return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
}

/**
*
*/

public function enableCachedSubscriptionsForThisRequest() {
$this->returnCachedSubscriptions = true;
}
Expand Down
5 changes: 3 additions & 2 deletions apps/dav/tests/unit/Avatars/AvatarHomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@ class AvatarHomeTest extends TestCase {
/** @var IAvatarManager | \PHPUnit_Framework_MockObject_MockObject */
private $avatarManager;

public function setUp(): void {
protected function setUp(): void {
parent::setUp();
$this->avatarManager = $this->createMock(IAvatarManager::class);
$this->home = new AvatarHome(['uri' => 'principals/users/admin'], $this->avatarManager);
}

/**
* @expectedException \Sabre\DAV\Exception\Forbidden
* @dataProvider providesForbiddenMethods
*/
public function testForbiddenMethods($method) {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);

$this->home->$method('');
}

Expand Down
4 changes: 2 additions & 2 deletions apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract class AbstractCalDavBackend extends TestCase {
const UNIT_TEST_GROUP = 'principals/groups/caldav-unit-test-group';
const UNIT_TEST_GROUP2 = 'principals/groups/caldav-unit-test-group2';

public function setUp(): void {
protected function setUp(): void {
parent::setUp();

$this->userManager = $this->createMock(IUserManager::class);
Expand Down Expand Up @@ -106,7 +106,7 @@ public function setUp(): void {
$this->cleanUpBackend();
}

public function tearDown(): void {
protected function tearDown(): void {
$this->cleanUpBackend();
parent::tearDown();
}
Expand Down
12 changes: 6 additions & 6 deletions apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testImplementsInterface($filterClass) {
public function testGetIdentifier($filterClass) {
/** @var IFilter $filter */
$filter = \OC::$server->query($filterClass);
$this->assertInternalType('string', $filter->getIdentifier());
$this->assertIsString($filter->getIdentifier());
}

/**
Expand All @@ -66,7 +66,7 @@ public function testGetIdentifier($filterClass) {
public function testGetName($filterClass) {
/** @var IFilter $filter */
$filter = \OC::$server->query($filterClass);
$this->assertInternalType('string', $filter->getName());
$this->assertIsString($filter->getName());
}

/**
Expand All @@ -77,7 +77,7 @@ public function testGetPriority($filterClass) {
/** @var IFilter $filter */
$filter = \OC::$server->query($filterClass);
$priority = $filter->getPriority();
$this->assertInternalType('int', $filter->getPriority());
$this->assertIsInt($filter->getPriority());
$this->assertGreaterThanOrEqual(0, $priority);
$this->assertLessThanOrEqual(100, $priority);
}
Expand All @@ -89,7 +89,7 @@ public function testGetPriority($filterClass) {
public function testGetIcon($filterClass) {
/** @var IFilter $filter */
$filter = \OC::$server->query($filterClass);
$this->assertInternalType('string', $filter->getIcon());
$this->assertIsString($filter->getIcon());
$this->assertStringStartsWith('http', $filter->getIcon());
}

Expand All @@ -100,7 +100,7 @@ public function testGetIcon($filterClass) {
public function testFilterTypes($filterClass) {
/** @var IFilter $filter */
$filter = \OC::$server->query($filterClass);
$this->assertInternalType('array', $filter->filterTypes([]));
$this->assertIsArray($filter->filterTypes([]));
}

/**
Expand All @@ -110,6 +110,6 @@ public function testFilterTypes($filterClass) {
public function testAllowedApps($filterClass) {
/** @var IFilter $filter */
$filter = \OC::$server->query($filterClass);
$this->assertInternalType('array', $filter->allowedApps());
$this->assertIsArray($filter->allowedApps());
}
}
3 changes: 2 additions & 1 deletion apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ public function dataGenerateObjectParameterThrows() {

/**
* @dataProvider dataGenerateObjectParameterThrows
* @expectedException \InvalidArgumentException
* @param mixed $eventData
*/
public function testGenerateObjectParameterThrows($eventData) {
$this->expectException(\InvalidArgumentException::class);

$this->invokePrivate($this->provider, 'generateObjectParameter', [$eventData]);
}

Expand Down
14 changes: 7 additions & 7 deletions apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testImplementsInterface($settingClass) {
public function testGetIdentifier($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('string', $setting->getIdentifier());
$this->assertIsString($setting->getIdentifier());
}

/**
Expand All @@ -65,7 +65,7 @@ public function testGetIdentifier($settingClass) {
public function testGetName($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('string', $setting->getName());
$this->assertIsString($setting->getName());
}

/**
Expand All @@ -76,7 +76,7 @@ public function testGetPriority($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$priority = $setting->getPriority();
$this->assertInternalType('int', $setting->getPriority());
$this->assertIsInt($setting->getPriority());
$this->assertGreaterThanOrEqual(0, $priority);
$this->assertLessThanOrEqual(100, $priority);
}
Expand All @@ -88,7 +88,7 @@ public function testGetPriority($settingClass) {
public function testCanChangeStream($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('bool', $setting->canChangeStream());
$this->assertIsBool($setting->canChangeStream());
}

/**
Expand All @@ -98,7 +98,7 @@ public function testCanChangeStream($settingClass) {
public function testIsDefaultEnabledStream($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('bool', $setting->isDefaultEnabledStream());
$this->assertIsBool($setting->isDefaultEnabledStream());
}

/**
Expand All @@ -108,7 +108,7 @@ public function testIsDefaultEnabledStream($settingClass) {
public function testCanChangeMail($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('bool', $setting->canChangeMail());
$this->assertIsBool($setting->canChangeMail());
}

/**
Expand All @@ -118,6 +118,6 @@ public function testCanChangeMail($settingClass) {
public function testIsDefaultEnabledMail($settingClass) {
/** @var ISetting $setting */
$setting = \OC::$server->query($settingClass);
$this->assertInternalType('bool', $setting->isDefaultEnabledMail());
$this->assertIsBool($setting->isDefaultEnabledMail());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EnablePluginTest extends TestCase {

protected $response;

public function setUp(): void {
protected function setUp(): void {
parent::setUp();

$this->server = $this->createMock(\Sabre\DAV\Server::class);
Expand Down
16 changes: 8 additions & 8 deletions apps/dav/tests/unit/CalDAV/CachedSubscriptionObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public function testGet() {
$this->assertEquals('BEGIN...', $calendarObject->get());
}

/**
* @expectedException \Sabre\DAV\Exception\MethodNotAllowed
* @expectedExceptionMessage Creating objects in a cached subscription is not allowed
*/

public function testPut() {
$this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
$this->expectExceptionMessage('Creating objects in a cached subscription is not allowed');

$backend = $this->createMock(CalDavBackend::class);
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
Expand All @@ -72,11 +72,11 @@ public function testPut() {
$calendarObject->put('');
}

/**
* @expectedException \Sabre\DAV\Exception\MethodNotAllowed
* @expectedExceptionMessage Deleting objects in a cached subscription is not allowed
*/

public function testDelete() {
$this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
$this->expectExceptionMessage('Deleting objects in a cached subscription is not allowed');

$backend = $this->createMock(CalDavBackend::class);
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
Expand Down
16 changes: 8 additions & 8 deletions apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ public function testPropPatch() {
$calendar->propPatch($propPatch);
}

/**
* @expectedException \Sabre\DAV\Exception\NotFound
* @expectedExceptionMessage Calendar object not found
*/

public function testGetChild() {
$this->expectException(\Sabre\DAV\Exception\NotFound::class);
$this->expectExceptionMessage('Calendar object not found');

$backend = $this->createMock(CalDavBackend::class);
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
Expand Down Expand Up @@ -235,11 +235,11 @@ public function testGetMultipleChildren() {
$this->assertInstanceOf(CachedSubscriptionObject::class, $res[1]);
}

/**
* @expectedException \Sabre\DAV\Exception\MethodNotAllowed
* @expectedExceptionMessage Creating objects in cached subscription is not allowed
*/

public function testCreateFile() {
$this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
$this->expectExceptionMessage('Creating objects in cached subscription is not allowed');

$backend = $this->createMock(CalDavBackend::class);
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
Expand Down
8 changes: 4 additions & 4 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ public function testCalendarObjectsOperations() {
$this->assertCount(0, $calendarObjects);
}

/**
* @expectedException \Sabre\DAV\Exception\BadRequest
* @expectedExceptionMessage Calendar object with uid already exists in this calendar collection.
*/

public function testMultipleCalendarObjectsWithSameUID() {
$this->expectException(\Sabre\DAV\Exception\BadRequest::class);
$this->expectExceptionMessage('Calendar object with uid already exists in this calendar collection.');

$calendarId = $this->createTestCalendar();

$calData = <<<'EOD'
Expand Down
8 changes: 4 additions & 4 deletions apps/dav/tests/unit/CalDAV/CalendarHomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public function testCreateCalendarValidName() {
$this->calendarHome->createExtendedCollection('name123', $mkCol);
}

/**
* @expectedException \Sabre\DAV\Exception\MethodNotAllowed
* @expectedExceptionMessage The resource you tried to create has a reserved name
*/

public function testCreateCalendarReservedName() {
$this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
$this->expectExceptionMessage('The resource you tried to create has a reserved name');

/** @var MkCol | \PHPUnit_Framework_MockObject_MockObject $mkCol */
$mkCol = $this->createMock(MkCol::class);

Expand Down
Loading