Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use phpunit8 where possible #494

Merged
merged 1 commit into from
Jan 29, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ vendor/
composer.lock
tests/cov/
tests/temp
tests/.phpunit.result.cache

#vim
.*.swp
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"require-dev" : {
"friendsofphp/php-cs-fixer": "~2.16.1",
"phpunit/phpunit" : "^7"
"phpunit/phpunit" : "^7 || ^8"
},
"suggest" : {
"hoa/bench" : "If you would like to run the benchmark scripts"
Expand Down
12 changes: 3 additions & 9 deletions tests/VObject/BirthdayCalendarGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,9 @@ public function testVcardStringWithEmptyBirthdayProperty()
);
}

/**
* @expectedException \Sabre\VObject\ParseException
*/
public function testParseException()
{
$this->expectException(ParseException::class);
$generator = new BirthdayCalendarGenerator();
$input = <<<EOT
BEGIN:FOO
Expand All @@ -473,11 +471,9 @@ public function testParseException()
$generator->setObjects($input);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidArgumentException()
{
$this->expectException(\InvalidArgumentException::class);
$generator = new BirthdayCalendarGenerator();
$input = <<<ICS
BEGIN:VCALENDAR
Expand All @@ -492,11 +488,9 @@ public function testInvalidArgumentException()
$generator->setObjects($input);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidArgumentExceptionForPartiallyInvalidArray()
{
$this->expectException(\InvalidArgumentException::class);
$generator = new BirthdayCalendarGenerator();
$input = [];

Expand Down
2 changes: 1 addition & 1 deletion tests/VObject/CliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CliTest extends TestCase
/** @var CliMock */
private $cli;

public function setUp()
public function setUp(): void
{
$this->cli = new CliMock();
$this->cli->stderr = fopen('php://memory', 'r+');
Expand Down
5 changes: 2 additions & 3 deletions tests/VObject/Component/VAlarmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DateTime;
use PHPUnit\Framework\TestCase;
use Sabre\VObject\InvalidDataException;
use Sabre\VObject\Reader;

class VAlarmTest extends TestCase
Expand Down Expand Up @@ -126,11 +127,9 @@ public function timeRangeTestData()
return $tests;
}

/**
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testInTimeRangeInvalidComponent()
{
$this->expectException(InvalidDataException::class);
$calendar = new VCalendar();
$valarm = $calendar->createComponent('VALARM');
$valarm->TRIGGER = '-P1D';
Expand Down
5 changes: 2 additions & 3 deletions tests/VObject/Component/VCalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DateTimeZone;
use PHPUnit\Framework\TestCase;
use Sabre\VObject;
use Sabre\VObject\InvalidDataException;

class VCalendarTest extends TestCase
{
Expand Down Expand Up @@ -330,11 +331,9 @@ public function expandData()
return $tests;
}

/**
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testBrokenEventExpand()
{
$this->expectException(InvalidDataException::class);
$input = 'BEGIN:VCALENDAR
CALSCALE:GREGORIAN
VERSION:2.0
Expand Down
26 changes: 8 additions & 18 deletions tests/VObject/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testMagicGet()
$this->assertInstanceOf('Sabre\\VObject\\Component', $event);
$this->assertEquals('VEVENT', $event->name);

$this->assertInternalType('null', $comp->vjournal);
$this->assertNull($comp->vjournal);
}

public function testMagicGetGroups()
Expand Down Expand Up @@ -174,20 +174,16 @@ public function testArrayAccessExists()
$this->assertTrue(isset($comp->vevent[1]));
}

/**
* @expectedException \LogicException
*/
public function testArrayAccessSet()
{
$this->expectException(\LogicException::class);
$comp = new VCalendar();
$comp['hey'] = 'hi there';
}

/**
* @expectedException \LogicException
*/
public function testArrayAccessUnset()
{
$this->expectException(\LogicException::class);
$comp = new VCalendar();
unset($comp[0]);
}
Expand Down Expand Up @@ -250,20 +246,16 @@ public function testAddComponentTwice()
$this->assertEquals('VEVENT', $comp->VEVENT->name);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testAddArgFail()
{
$this->expectException(\InvalidArgumentException::class);
$comp = new VCalendar();
$comp->add($comp->createComponent('VEVENT'), 'hello');
}

/**
* @expectedException \InvalidArgumentException
*/
public function testAddArgFail2()
{
$this->expectException(\InvalidArgumentException::class);
$comp = new VCalendar();
$comp->add([]);
}
Expand Down Expand Up @@ -293,7 +285,7 @@ public function testChildren()
$comp->add($comp->createComponent('VTODO'));

$r = $comp->children();
$this->assertInternalType('array', $r);
$this->assertIsArray($r);
$this->assertEquals(2, count($r));
}

Expand All @@ -305,7 +297,7 @@ public function testGetComponents()
$comp->add($comp->createComponent('VTODO'));

$r = $comp->getComponents();
$this->assertInternalType('array', $r);
$this->assertIsArray($r);
$this->assertEquals(1, count($r));
$this->assertEquals('VTODO', $r[0]->name);
}
Expand Down Expand Up @@ -414,11 +406,9 @@ public function testRemoveByObj()
$this->assertTrue(isset($comp->prop1));
}

/**
* @expectedException \InvalidArgumentException
*/
public function testRemoveNotFound()
{
$this->expectException(\InvalidArgumentException::class);
$comp = new VCalendar([], false);
$prop = $comp->createProperty('A', 'B');
$comp->remove($prop);
Expand Down
20 changes: 7 additions & 13 deletions tests/VObject/DateTimeParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ public function testParseICalendarDurationDateInterval()
$this->assertEquals($expected, DateTimeParser::parseDuration('-PT3M'));
}

/**
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testParseICalendarDurationFail()
{
$this->expectException(InvalidDataException::class);
DateTimeParser::parseDuration('P1X', true);
}

Expand All @@ -50,19 +48,19 @@ public function testParseICalendarDateTime()

/**
* @depends testParseICalendarDateTime
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testParseICalendarDateTimeBadFormat()
{
$this->expectException(InvalidDataException::class);
$dateTime = DateTimeParser::parseDateTime('20100316T141405 ');
}

/**
* @depends testParseICalendarDateTime
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testParseICalendarDateTimeInvalidTime()
{
$this->expectException(InvalidDataException::class);
$dateTime = DateTimeParser::parseDateTime('20100316T251405');
}

Expand Down Expand Up @@ -143,19 +141,19 @@ public function testParseICalendarDateTimeGreaterThan4000()

/**
* @depends testParseICalendarDate
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testParseICalendarDateBadFormat()
{
$this->expectException(InvalidDataException::class);
$dateTime = DateTimeParser::parseDate('20100316T141405');
}

/**
* @depends testParseICalendarDate
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testParseICalendarDateInvalidDate()
{
$this->expectException(InvalidDataException::class);
$dateTime = DateTimeParser::parseDate('20101331');
}

Expand All @@ -170,19 +168,15 @@ public function testVCardDate($input, $output)
);
}

/**
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testBadVCardDate()
{
$this->expectException(InvalidDataException::class);
DateTimeParser::parseVCardDateTime('1985---01');
}

/**
* @expectedException \Sabre\VObject\InvalidDataException
*/
public function testBadVCardTime()
{
$this->expectException(InvalidDataException::class);
DateTimeParser::parseVCardTime('23:12:166');
}

Expand Down
4 changes: 1 addition & 3 deletions tests/VObject/FreeBusyGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ public function testGeneratorBaseObject()
$this->assertEquals('PUBLISH', $result->METHOD->getValue());
}

/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidArg()
{
$this->expectException(\InvalidArgumentException::class);
$gen = new FreeBusyGenerator(
new \DateTime('2012-01-01'),
new \DateTime('2012-12-31'),
Expand Down
16 changes: 4 additions & 12 deletions tests/VObject/ITip/BrokerNewEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ public function testSimpleInvite()
$this->parse(null, $message, $expected, 'mailto:[email protected]');
}

/**
* @expectedException \Sabre\VObject\ITip\ITipException
*/
public function testBrokenEventUIDMisMatch()
{
$this->expectException(ITipException::class);
$message = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
Expand All @@ -105,11 +103,9 @@ public function testBrokenEventUIDMisMatch()
$this->parse(null, $message, [], 'mailto:[email protected]');
}

/**
* @expectedException \Sabre\VObject\ITip\ITipException
*/
public function testBrokenEventOrganizerMisMatch()
{
$this->expectException(ITipException::class);
$message = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
Expand Down Expand Up @@ -456,11 +452,9 @@ public function testScheduleAgentClient()
$this->parse(null, $message, [], 'mailto:[email protected]');
}

/**
* @expectedException \Sabre\VObject\ITip\ITipException
*/
public function testMultipleUID()
{
$this->expectException(ITipException::class);
$message = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
Expand Down Expand Up @@ -489,11 +483,9 @@ public function testMultipleUID()
$this->parse(null, $message, [], 'mailto:[email protected]');
}

/**
* @expectedException \Sabre\VObject\ITip\SameOrganizerForAllComponentsException
*/
public function testChangingOrganizers()
{
$this->expectException(SameOrganizerForAllComponentsException::class);
$message = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
Expand Down
4 changes: 1 addition & 3 deletions tests/VObject/IssueUndefinedIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

class IssueUndefinedIndexTest extends TestCase
{
/**
* @expectedException \Sabre\VObject\ParseException
*/
public function testRead()
{
$this->expectException(ParseException::class);
$input = <<<VCF
BEGIN:VCARD
VERSION:3.0
Expand Down
5 changes: 2 additions & 3 deletions tests/VObject/Parser/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PHPUnit\Framework\TestCase;
use Sabre\VObject;
use Sabre\VObject\ParseException;

class JsonTest extends TestCase
{
Expand Down Expand Up @@ -371,11 +372,9 @@ public function testParseStreamArg()
$this->assertEquals('foo', $result->FN->getValue());
}

/**
* @expectedException \Sabre\VObject\ParseException
*/
public function testParseInvalidData()
{
$this->expectException(ParseException::class);
$json = new Json();
$input = [
'vlist',
Expand Down
Loading