Skip to content

Commit

Permalink
Merge pull request #1452 from phil-davis/self-assert-phpunit
Browse files Browse the repository at this point in the history
Call static assert functions with self::
  • Loading branch information
phil-davis authored Feb 8, 2023
2 parents 6e04024 + b4b37c4 commit 2d8f6d9
Show file tree
Hide file tree
Showing 195 changed files with 2,086 additions and 2,086 deletions.
140 changes: 70 additions & 70 deletions tests/Sabre/CalDAV/Backend/AbstractPDOTest.php

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions tests/Sabre/CalDAV/Backend/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testUpdateCalendar()
$abstract->updateCalendar('randomid', $propPatch);
$result = $propPatch->commit();

$this->assertFalse($result);
self::assertFalse($result);
}

public function testCalendarQuery()
Expand All @@ -38,25 +38,25 @@ public function testCalendarQuery()
'time-range' => null,
];

$this->assertEquals([
self::assertEquals([
'event1.ics',
], $abstract->calendarQuery(1, $filters));
}

public function testGetCalendarObjectByUID()
{
$abstract = new AbstractMock();
$this->assertNull(
self::assertNull(
$abstract->getCalendarObjectByUID('principal1', 'zim')
);
$this->assertEquals(
self::assertEquals(
'cal1/event1.ics',
$abstract->getCalendarObjectByUID('principal1', 'foo')
);
$this->assertNull(
self::assertNull(
$abstract->getCalendarObjectByUID('principal3', 'foo')
);
$this->assertNull(
self::assertNull(
$abstract->getCalendarObjectByUID('principal1', 'shared')
);
}
Expand Down Expand Up @@ -84,7 +84,7 @@ public function testGetMultipleCalendarObjects()
],
];

$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);
}
}

Expand Down
52 changes: 26 additions & 26 deletions tests/Sabre/CalDAV/Backend/SimplePDOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function setup(): void
public function testConstruct()
{
$backend = new SimplePDO($this->pdo);
$this->assertTrue($backend instanceof SimplePDO);
self::assertTrue($backend instanceof SimplePDO);
}

/**
Expand All @@ -58,7 +58,7 @@ public function testGetCalendarsForUserNoCalendars()
{
$backend = new SimplePDO($this->pdo);
$calendars = $backend->getCalendarsForUser('principals/user2');
$this->assertEquals([], $calendars);
self::assertEquals([], $calendars);
}

/**
Expand All @@ -78,12 +78,12 @@ public function testCreateCalendarAndFetch()
'uri' => 'somerandomid',
];

$this->assertIsArray($calendars);
$this->assertEquals(1, count($calendars));
self::assertIsArray($calendars);
self::assertEquals(1, count($calendars));

foreach ($elementCheck as $name => $value) {
$this->assertArrayHasKey($name, $calendars[0]);
$this->assertEquals($value, $calendars[0][$name]);
self::assertArrayHasKey($name, $calendars[0]);
self::assertEquals($value, $calendars[0][$name]);
}
}

Expand All @@ -107,7 +107,7 @@ public function testUpdateCalendarAndFetch()
$result = $propPatch->commit();

// Verifying the result of the update
$this->assertFalse($result);
self::assertFalse($result);
}

/**
Expand All @@ -124,7 +124,7 @@ public function testDeleteCalendar()
$backend->deleteCalendar($returnedId);

$calendars = $backend->getCalendarsForUser('principals/user2');
$this->assertEquals([], $calendars);
self::assertEquals([], $calendars);
}

public function testCreateCalendarObject()
Expand All @@ -137,7 +137,7 @@ public function testCreateCalendarObject()
$backend->createCalendarObject($returnedId, 'random-id', $object);

$result = $this->pdo->query('SELECT calendardata FROM simple_calendarobjects WHERE uri = "random-id"');
$this->assertEquals([
self::assertEquals([
'calendardata' => $object,
], $result->fetch(\PDO::FETCH_ASSOC));
}
Expand Down Expand Up @@ -174,9 +174,9 @@ public function testGetMultipleObjects()
foreach ($check as $index => $props) {
foreach ($props as $key => $value) {
if ('lastmodified' !== $key) {
$this->assertEquals($value, $result[$index][$key]);
self::assertEquals($value, $result[$index][$key]);
} else {
$this->assertTrue(isset($result[$index][$key]));
self::assertTrue(isset($result[$index][$key]));
}
}
}
Expand All @@ -195,11 +195,11 @@ public function testGetCalendarObjects()

$data = $backend->getCalendarObjects($returnedId);

$this->assertEquals(1, count($data));
self::assertEquals(1, count($data));
$data = $data[0];

$this->assertEquals('random-id', $data['uri']);
$this->assertEquals(strlen($object), $data['size']);
self::assertEquals('random-id', $data['uri']);
self::assertEquals(strlen($object), $data['size']);
}

/**
Expand All @@ -213,10 +213,10 @@ public function testGetCalendarObjectByUID()
$object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
$backend->createCalendarObject($returnedId, 'random-id', $object);

$this->assertNull(
self::assertNull(
$backend->getCalendarObjectByUID('principals/user2', 'bar')
);
$this->assertEquals(
self::assertEquals(
'somerandomid/random-id',
$backend->getCalendarObjectByUID('principals/user2', 'foo')
);
Expand All @@ -237,8 +237,8 @@ public function testUpdateCalendarObject()

$data = $backend->getCalendarObject($returnedId, 'random-id');

$this->assertEquals($object2, $data['calendardata']);
$this->assertEquals('random-id', $data['uri']);
self::assertEquals($object2, $data['calendardata']);
self::assertEquals('random-id', $data['uri']);
}

/**
Expand All @@ -254,7 +254,7 @@ public function testDeleteCalendarObject()
$backend->deleteCalendarObject($returnedId, 'random-id');

$data = $backend->getCalendarObject($returnedId, 'random-id');
$this->assertNull($data);
self::assertNull($data);
}

public function testCalendarQueryNoResult()
Expand All @@ -276,7 +276,7 @@ public function testCalendarQueryNoResult()
'time-range' => null,
];

$this->assertEquals([
self::assertEquals([
], $abstract->calendarQuery(1, $filters));
}

Expand All @@ -302,7 +302,7 @@ public function testCalendarQueryTodo()
'time-range' => null,
];

$this->assertEquals([
self::assertEquals([
'todo',
], $backend->calendarQuery(1, $filters));
}
Expand Down Expand Up @@ -337,7 +337,7 @@ public function testCalendarQueryTodoNotMatch()
'time-range' => null,
];

$this->assertEquals([
self::assertEquals([
], $backend->calendarQuery(1, $filters));
}

Expand All @@ -356,8 +356,8 @@ public function testCalendarQueryNoFilter()
];

$result = $backend->calendarQuery(1, $filters);
$this->assertTrue(in_array('todo', $result));
$this->assertTrue(in_array('event', $result));
self::assertTrue(in_array('todo', $result));
self::assertTrue(in_array('event', $result));
}

public function testCalendarQueryTimeRange()
Expand Down Expand Up @@ -386,7 +386,7 @@ public function testCalendarQueryTimeRange()
'time-range' => null,
];

$this->assertEquals([
self::assertEquals([
'event2',
], $backend->calendarQuery(1, $filters));
}
Expand Down Expand Up @@ -417,7 +417,7 @@ public function testCalendarQueryTimeRangeNoEnd()
'time-range' => null,
];

$this->assertEquals([
self::assertEquals([
'event2',
], $backend->calendarQuery(1, $filters));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Sabre/CalDAV/CalendarHomeNotificationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function testGetChildrenNoSupport()
$backend = new Backend\Mock();
$calendarHome = new CalendarHome($backend, ['uri' => 'principals/user']);

$this->assertEquals(
self::assertEquals(
[],
$calendarHome->getChildren()
);
Expand All @@ -31,14 +31,14 @@ public function testGetChildren()
$calendarHome = new CalendarHome($backend, ['uri' => 'principals/user']);

$result = $calendarHome->getChildren();
$this->assertEquals('notifications', $result[0]->getName());
self::assertEquals('notifications', $result[0]->getName());
}

public function testGetChild()
{
$backend = new Backend\MockSharing();
$calendarHome = new CalendarHome($backend, ['uri' => 'principals/user']);
$result = $calendarHome->getChild('notifications');
$this->assertEquals('notifications', $result->getName());
self::assertEquals('notifications', $result->getName());
}
}
10 changes: 5 additions & 5 deletions tests/Sabre/CalDAV/CalendarHomeSharedCalendarsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public function getInstance()
public function testSimple()
{
$instance = $this->getInstance();
$this->assertEquals('user1', $instance->getName());
self::assertEquals('user1', $instance->getName());
}

public function testGetChildren()
{
$instance = $this->getInstance();
$children = $instance->getChildren();
$this->assertEquals(3, count($children));
self::assertEquals(3, count($children));

// Testing if we got all the objects back.
$sharedCalendars = 0;
Expand All @@ -62,14 +62,14 @@ public function testGetChildren()
$hasNotifications = true;
}
}
$this->assertEquals(2, $sharedCalendars);
$this->assertTrue($hasNotifications);
self::assertEquals(2, $sharedCalendars);
self::assertTrue($hasNotifications);
}

public function testShareReply()
{
$instance = $this->getInstance();
$result = $instance->shareReply('uri', DAV\Sharing\Plugin::INVITE_DECLINED, 'curi', '1');
$this->assertNull($result);
self::assertNull($result);
}
}
6 changes: 3 additions & 3 deletions tests/Sabre/CalDAV/CalendarHomeSubscriptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public function getInstance()
public function testSimple()
{
$instance = $this->getInstance();
$this->assertEquals('user1', $instance->getName());
self::assertEquals('user1', $instance->getName());
}

public function testGetChildren()
{
$instance = $this->getInstance();
$children = $instance->getChildren();
$this->assertEquals(1, count($children));
self::assertEquals(1, count($children));
foreach ($children as $child) {
if ($child instanceof Subscriptions\Subscription) {
return;
Expand All @@ -56,7 +56,7 @@ public function testCreateSubscription()
$instance->createExtendedCollection('sub2', new MkCol($rt, $props));

$children = $instance->getChildren();
$this->assertEquals(2, count($children));
self::assertEquals(2, count($children));
}

public function testNoSubscriptionSupport()
Expand Down
20 changes: 10 additions & 10 deletions tests/Sabre/CalDAV/CalendarHomeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function setup(): void

public function testSimple()
{
$this->assertEquals('user1', $this->usercalendars->getName());
self::assertEquals('user1', $this->usercalendars->getName());
}

/**
Expand All @@ -43,18 +43,18 @@ public function testGetChildNotFound()

public function testChildExists()
{
$this->assertFalse($this->usercalendars->childExists('foo'));
$this->assertTrue($this->usercalendars->childExists('UUID-123467'));
self::assertFalse($this->usercalendars->childExists('foo'));
self::assertTrue($this->usercalendars->childExists('UUID-123467'));
}

public function testGetOwner()
{
$this->assertEquals('principals/user1', $this->usercalendars->getOwner());
self::assertEquals('principals/user1', $this->usercalendars->getOwner());
}

public function testGetGroup()
{
$this->assertNull($this->usercalendars->getGroup());
self::assertNull($this->usercalendars->getGroup());
}

public function testGetACL()
Expand Down Expand Up @@ -86,7 +86,7 @@ public function testGetACL()
'protected' => true,
],
];
$this->assertEquals($expected, $this->usercalendars->getACL());
self::assertEquals($expected, $this->usercalendars->getACL());
}

public function testSetACL()
Expand Down Expand Up @@ -118,7 +118,7 @@ public function testDelete()
*/
public function testGetLastModified()
{
$this->assertNull($this->usercalendars->getLastModified());
self::assertNull($this->usercalendars->getLastModified());
}

/**
Expand Down Expand Up @@ -149,9 +149,9 @@ public function testCreateExtendedCollection()
[]
);
$result = $this->usercalendars->createExtendedCollection('newcalendar', $mkCol);
$this->assertNull($result);
self::assertNull($result);
$cals = $this->backend->getCalendarsForUser('principals/user1');
$this->assertEquals(3, count($cals));
self::assertEquals(3, count($cals));
}

/**
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testCreateExtendedCollectionNotACalendar()

public function testGetSupportedPrivilegesSet()
{
$this->assertNull($this->usercalendars->getSupportedPrivilegeSet());
self::assertNull($this->usercalendars->getSupportedPrivilegeSet());
}

public function testShareReplyFail()
Expand Down
Loading

0 comments on commit 2d8f6d9

Please sign in to comment.