From e5dcb90179904633ded3dfa80c8a26734d6078e1 Mon Sep 17 00:00:00 2001 From: Justin Svrcek Date: Mon, 11 Jan 2021 10:18:11 -0500 Subject: [PATCH 1/6] update composer version control to allow php 8, added php versions to travis --- .travis.yml | 3 +++ composer.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ca3d1a2..1c6086a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 + - 7.4 + - 8.0 sudo: false diff --git a/composer.json b/composer.json index fa75da5..4538ea6 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^5.6 || ^7.0" + "php": ">=5.6" }, "require-dev": { "phpunit/phpunit": "^4.8 || ^5.5" From 1f5455af1fdc371e0fb2010527d36756d0bde067 Mon Sep 17 00:00:00 2001 From: Justin Svrcek Date: Mon, 11 Jan 2021 10:47:13 -0500 Subject: [PATCH 2/6] adjust phpunit version constraint --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4538ea6..7e59fdf 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.5" + "phpunit/phpunit": "^4.8 || ^5.5 || >=8.0" }, "autoload": { "psr-4": { From b5721cc477a615e0c8a448ea4526861913ba3955 Mon Sep 17 00:00:00 2001 From: Justin Svrcek Date: Mon, 11 Jan 2021 11:46:38 -0500 Subject: [PATCH 3/6] another try with phpunit version constraint --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7e59fdf..c2d57e7 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.5 || >=8.0" + "phpunit/phpunit": "^4.8 || ^5.5 || ^6.0 || >=9.0" }, "autoload": { "psr-4": { From f4bf4a2b240b13646e46414a504172d131efdb8e Mon Sep 17 00:00:00 2001 From: Justin Svrcek Date: Mon, 11 Jan 2021 14:17:37 -0500 Subject: [PATCH 4/6] update tests to use phpunit namespaces --- composer.json | 2 +- tests/CalendarExportTest.php | 3 ++- tests/CalendarStreamTest.php | 3 ++- tests/Model/CalendarEventTest.php | 3 ++- tests/Model/CalendarTest.php | 3 ++- tests/Model/Recurrence/RecurrenceRuleTest.php | 3 ++- tests/Model/Relationship/AttendeeTest.php | 3 ++- tests/Model/Relationship/OrganizerTest.php | 3 ++- tests/Utility/FormatterTest.php | 3 ++- tests/Utility/ProviderTest.php | 3 ++- 10 files changed, 19 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index c2d57e7..7b6409f 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.5 || ^6.0 || >=9.0" + "phpunit/phpunit": "^4.8 || ^5.5 || >=6.0" }, "autoload": { "psr-4": { diff --git a/tests/CalendarExportTest.php b/tests/CalendarExportTest.php index 05a62fe..d465f2c 100644 --- a/tests/CalendarExportTest.php +++ b/tests/CalendarExportTest.php @@ -22,8 +22,9 @@ use Jsvrcek\ICS\CalendarExport; use Jsvrcek\ICS\Model\Calendar; use Jsvrcek\ICS\Model\CalendarEvent; +use PHPUnit\Framework\TestCase; -class CalendarExportTest extends \PHPUnit_Framework_TestCase +class CalendarExportTest extends TestCase { /** * @covers Jsvrcek\ICS\CalendarExport::getStream diff --git a/tests/CalendarStreamTest.php b/tests/CalendarStreamTest.php index aee2e53..117f0ee 100644 --- a/tests/CalendarStreamTest.php +++ b/tests/CalendarStreamTest.php @@ -4,8 +4,9 @@ use Jsvrcek\ICS\CalendarStream; use Jsvrcek\ICS\Constants; +use PHPUnit\Framework\TestCase; -class CalendarStreamTest extends \PHPUnit_Framework_TestCase +class CalendarStreamTest extends TestCase { public function testGetStream() { diff --git a/tests/Model/CalendarEventTest.php b/tests/Model/CalendarEventTest.php index b7e3212..e56b935 100644 --- a/tests/Model/CalendarEventTest.php +++ b/tests/Model/CalendarEventTest.php @@ -4,11 +4,12 @@ use Jsvrcek\ICS\Model\CalendarEvent; use Jsvrcek\ICS\Exception\CalendarEventException; +use PHPUnit\Framework\TestCase; /** * Generated by PHPUnit_SkeletonGenerator on 2013-10-20 at 12:03:54. */ -class CalendarEventTest extends \PHPUnit_Framework_TestCase +class CalendarEventTest extends TestCase { /** * @var CalendarEvent diff --git a/tests/Model/CalendarTest.php b/tests/Model/CalendarTest.php index 4fa227f..2230d5a 100644 --- a/tests/Model/CalendarTest.php +++ b/tests/Model/CalendarTest.php @@ -3,11 +3,12 @@ namespace Jsvrcek\ICS\Tests\Model; use Jsvrcek\ICS\Model\Calendar; +use PHPUnit\Framework\TestCase; /** * Generated by PHPUnit_SkeletonGenerator on 2013-10-20 at 15:24:14. */ -class CalendarTest extends \PHPUnit_Framework_TestCase +class CalendarTest extends TestCase { /** * @covers Jsvrcek\ICS\Model\Calendar::__construct diff --git a/tests/Model/Recurrence/RecurrenceRuleTest.php b/tests/Model/Recurrence/RecurrenceRuleTest.php index faaef6d..d1b046f 100644 --- a/tests/Model/Recurrence/RecurrenceRuleTest.php +++ b/tests/Model/Recurrence/RecurrenceRuleTest.php @@ -8,8 +8,9 @@ use Jsvrcek\ICS\Utility\Formatter; use Jsvrcek\ICS\Model\Recurrence\RecurrenceRule; +use PHPUnit\Framework\TestCase; -class RecurrenceRuleTest extends \PHPUnit_Framework_TestCase +class RecurrenceRuleTest extends TestCase { /** * @var RecurrenceRule diff --git a/tests/Model/Relationship/AttendeeTest.php b/tests/Model/Relationship/AttendeeTest.php index ae077be..95c7186 100644 --- a/tests/Model/Relationship/AttendeeTest.php +++ b/tests/Model/Relationship/AttendeeTest.php @@ -4,8 +4,9 @@ use Jsvrcek\ICS\Utility\Formatter; use Jsvrcek\ICS\Model\Relationship\Attendee; +use PHPUnit\Framework\TestCase; -class AttendeeTest extends \PHPUnit_Framework_TestCase +class AttendeeTest extends TestCase { /** * @var Attendee diff --git a/tests/Model/Relationship/OrganizerTest.php b/tests/Model/Relationship/OrganizerTest.php index f030595..03514a2 100644 --- a/tests/Model/Relationship/OrganizerTest.php +++ b/tests/Model/Relationship/OrganizerTest.php @@ -4,8 +4,9 @@ use Jsvrcek\ICS\Utility\Formatter; use Jsvrcek\ICS\Model\Relationship\Organizer; +use PHPUnit\Framework\TestCase; -class OrganizerTest extends \PHPUnit_Framework_TestCase +class OrganizerTest extends TestCase { /** * @var Organizer diff --git a/tests/Utility/FormatterTest.php b/tests/Utility/FormatterTest.php index a1400f0..80cb083 100644 --- a/tests/Utility/FormatterTest.php +++ b/tests/Utility/FormatterTest.php @@ -3,8 +3,9 @@ namespace Jsvrcek\ICS\Tests\Utility; use Jsvrcek\ICS\Utility\Formatter; +use PHPUnit\Framework\TestCase; -class FormatterTest extends \PHPUnit_Framework_TestCase +class FormatterTest extends TestCase { /** * @covers Jsvrcek\ICS\Formatter::getFormattedDateTime diff --git a/tests/Utility/ProviderTest.php b/tests/Utility/ProviderTest.php index b2780b2..d6a7a4d 100644 --- a/tests/Utility/ProviderTest.php +++ b/tests/Utility/ProviderTest.php @@ -3,8 +3,9 @@ namespace Jsvrcek\ICS\Tests\Utility; use Jsvrcek\ICS\Utility\Provider; +use PHPUnit\Framework\TestCase; -class ProviderTest extends \PHPUnit_Framework_TestCase +class ProviderTest extends TestCase { /** * @covers Jsvrcek\ICS\Utility\Provider::first From 07d60fb4d9d1b98d2c6397731dc89db63e78a415 Mon Sep 17 00:00:00 2001 From: Justin Svrcek Date: Mon, 11 Jan 2021 16:17:22 -0500 Subject: [PATCH 5/6] remove incompatibility with later versions of phpunit --- tests/Model/CalendarEventTest.php | 40 ++++---------- tests/Model/Recurrence/RecurrenceRuleTest.php | 54 ++++++------------- tests/Model/Relationship/AttendeeTest.php | 29 ++-------- tests/Model/Relationship/OrganizerTest.php | 29 ++-------- 4 files changed, 35 insertions(+), 117 deletions(-) diff --git a/tests/Model/CalendarEventTest.php b/tests/Model/CalendarEventTest.php index e56b935..c6321f5 100644 --- a/tests/Model/CalendarEventTest.php +++ b/tests/Model/CalendarEventTest.php @@ -11,43 +11,21 @@ */ class CalendarEventTest extends TestCase { - /** - * @var CalendarEvent - */ - protected $object; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - * @return CalendarEvent - */ - protected function setUp() - { - $this->object = new CalendarEvent; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - /** * @covers Jsvrcek\ICS\Model\CalendarEvent::setStart */ public function testSetStart() { $start = new \DateTime(); + $object = new CalendarEvent; - $this->object->setStart($start); + $object->setStart($start); // test start - $this->assertEquals($start, $this->object->getStart()); + $this->assertEquals($start, $object->getStart()); //test default end - $this->assertEquals($start->add(\DateInterval::createFromDateString('30 minutes')), $this->object->getEnd()); + $this->assertEquals($start->add(\DateInterval::createFromDateString('30 minutes')), $object->getEnd()); } /** @@ -57,11 +35,13 @@ public function testSetStart() */ public function testSetEndDateEarlierThanStart() { + $object = new CalendarEvent; + $start = new \DateTime('now'); $end = new \DateTime('yesterday'); - $this->object->setStart($start); - $this->object->setEnd($end); + $object->setStart($start); + $object->setEnd($end); } /** @@ -71,8 +51,10 @@ public function testSetEndDateEarlierThanStart() */ public function testSetEndWithoutStart() { + $object = new CalendarEvent; + $end = new \DateTime('yesterday'); - $this->object->setEnd($end); + $object->setEnd($end); } } diff --git a/tests/Model/Recurrence/RecurrenceRuleTest.php b/tests/Model/Recurrence/RecurrenceRuleTest.php index d1b046f..c288b1a 100644 --- a/tests/Model/Recurrence/RecurrenceRuleTest.php +++ b/tests/Model/Recurrence/RecurrenceRuleTest.php @@ -12,35 +12,14 @@ class RecurrenceRuleTest extends TestCase { - /** - * @var RecurrenceRule - */ - protected $object; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - * @return Rule - */ - protected function setUp() - { - $this->object = new RecurrenceRule(new Formatter()); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - /** * @covers Jsvrcek\ICS\Model\Recurrence\RecurrentRule::__toString() */ public function testToString() { - $this->object + $object = new RecurrenceRule(new Formatter()); + + $object ->setFrequency(new Frequency(Frequency::YEARLY)) ->setInterval(2) ->setCount(10) @@ -51,12 +30,12 @@ public function testToString() $expected = 'RRULE:FREQ=YEARLY;INTERVAL=2;UNTIL=20500101T000000Z;COUNT=10;BYDAY=10MO,-10TU'; - $this->assertEquals($expected, $this->object->__toString()); + $this->assertEquals($expected, $object->__toString()); //get a new object, test byMonth - $this->setUp(); + $object = new RecurrenceRule(new Formatter()); - $this->object + $object ->setFrequency(new Frequency(Frequency::WEEKLY)) ->setInterval(1) ->addByMonth(2) @@ -66,7 +45,7 @@ public function testToString() $expected = 'RRULE:FREQ=WEEKLY;INTERVAL=1;BYMONTH=2,3,4'; - $this->assertEquals($expected, $this->object->__toString()); + $this->assertEquals($expected, $object->__toString()); } /** @@ -75,25 +54,24 @@ public function testToString() */ public function testParse() { - //reset instance - $this->setUp(); + $object = new RecurrenceRule(new Formatter()); $rRuleString = 'RRULE:FREQ=YEARLY;INTERVAL=2'; - $this->object->parse($rRuleString); - $this->assertEquals($rRuleString, $this->object->__toString()); + $object->parse($rRuleString); + $this->assertEquals($rRuleString, $object->__toString()); $rRuleString = 'RRULE:FREQ=WEEKLY;INTERVAL=4'; - $this->object->parse($rRuleString); - $this->assertEquals($rRuleString, $this->object->__toString()); + $object->parse($rRuleString); + $this->assertEquals($rRuleString, $object->__toString()); $rRuleString = 'RRULE:FREQ=WEEKLY;INTERVAL=4;UNTIL=20500101T000000Z'; - $this->object->parse($rRuleString); - $this->assertEquals($rRuleString, $this->object->__toString()); + $object->parse($rRuleString); + $this->assertEquals($rRuleString, $object->__toString()); /* $rRuleString = 'RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=10;BYDAY=10MO,-10TU'; - $this->object->parse($rRuleString); - $this->assertEquals($rRuleString, $this->object->__toString()); + $object->parse($rRuleString); + $this->assertEquals($rRuleString, $object->__toString()); */ } } diff --git a/tests/Model/Relationship/AttendeeTest.php b/tests/Model/Relationship/AttendeeTest.php index 95c7186..22cd146 100644 --- a/tests/Model/Relationship/AttendeeTest.php +++ b/tests/Model/Relationship/AttendeeTest.php @@ -8,35 +8,14 @@ class AttendeeTest extends TestCase { - /** - * @var Attendee - */ - protected $object; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - * @return Attendee - */ - protected function setUp() - { - $this->object = new Attendee(new Formatter()); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - /** * @covers Jsvrcek\ICS\Model\Attendee::__toString() */ public function testToString() { - $this->object + $object = new Attendee(new Formatter()); + + $object ->setValue('joe-smith@example.com') ->setName('Joe Smith') ->setCalendarUserType('INDIVIDUAL') @@ -52,6 +31,6 @@ public function testToString() $expected = 'ATTENDEE;CUTYPE=INDIVIDUAL;MEMBER="mailto:list@example.com";ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE;DELEGATED-TO="mailto:sue@example.com","mailto:jane@example.com";DELEGATED-FROM="mailto:mary@example.com";SENT-BY="jack@example.com";CN=Joe Smith;LANGUAGE=en:mailto:joe-smith@example.com'; - $this->assertEquals($expected, $this->object->__toString()); + $this->assertEquals($expected, $object->__toString()); } } diff --git a/tests/Model/Relationship/OrganizerTest.php b/tests/Model/Relationship/OrganizerTest.php index 03514a2..bd4eb9e 100644 --- a/tests/Model/Relationship/OrganizerTest.php +++ b/tests/Model/Relationship/OrganizerTest.php @@ -8,35 +8,14 @@ class OrganizerTest extends TestCase { - /** - * @var Organizer - */ - protected $object; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - * @return Organizer - */ - protected function setUp() - { - $this->object = new Organizer(new Formatter()); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - /** * @covers Jsvrcek\ICS\Model\Organizer::__toString() */ public function testToString() { - $this->object + $object = new Organizer(new Formatter()); + + $object ->setValue('leonardo@example.it') ->setName('Leonardo Da Vinci') ->setLanguage('it') @@ -45,6 +24,6 @@ public function testToString() $expected = 'ORGANIZER;SENT-BY="piero@example.com";CN=Leonardo Da Vinci;DIR="http://en.wikipedia.org/wiki/Leonardo_da_Vinci";LANGUAGE=it:mailto:leonardo@example.it'; - $this->assertEquals($expected, $this->object->__toString()); + $this->assertEquals($expected, $object->__toString()); } } From 68d2ff2819e5173d5dcc01fae204d995a65b6bc9 Mon Sep 17 00:00:00 2001 From: Justin Svrcek Date: Tue, 12 Jan 2021 10:01:53 -0500 Subject: [PATCH 6/6] refactor exception tests to not use annotations --- tests/Model/CalendarEventTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/Model/CalendarEventTest.php b/tests/Model/CalendarEventTest.php index c6321f5..38d93e7 100644 --- a/tests/Model/CalendarEventTest.php +++ b/tests/Model/CalendarEventTest.php @@ -30,11 +30,12 @@ public function testSetStart() /** * @covers Jsvrcek\ICS\Model\CalendarEvent::setEnd - * @expectedException Jsvrcek\ICS\Exception\CalendarEventException - * @expectedExceptionMessage End DateTime must be greater than Start DateTime */ public function testSetEndDateEarlierThanStart() { + $this->expectException(CalendarEventException::class); + $this->expectExceptionMessage('End DateTime must be greater than Start DateTime'); + $object = new CalendarEvent; $start = new \DateTime('now'); @@ -46,11 +47,12 @@ public function testSetEndDateEarlierThanStart() /** * @covers Jsvrcek\ICS\Model\CalendarEvent::setEnd - * @expectedException Jsvrcek\ICS\Exception\CalendarEventException - * @expectedExceptionMessage You must set the Start time before setting the End Time of a CalendarEvent */ public function testSetEndWithoutStart() { + $this->expectException(CalendarEventException::class); + $this->expectExceptionMessage('You must set the Start time before setting the End Time of a CalendarEvent'); + $object = new CalendarEvent; $end = new \DateTime('yesterday');