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..7b6409f 100644 --- a/composer.json +++ b/composer.json @@ -11,10 +11,10 @@ } ], "require": { - "php": "^5.6 || ^7.0" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.5" + "phpunit/phpunit": "^4.8 || ^5.5 || >=6.0" }, "autoload": { "psr-4": { diff --git a/tests/CalendarExportTest.php b/tests/CalendarExportTest.php index 7158531..ac30471 100644 --- a/tests/CalendarExportTest.php +++ b/tests/CalendarExportTest.php @@ -23,8 +23,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..38d93e7 100644 --- a/tests/Model/CalendarEventTest.php +++ b/tests/Model/CalendarEventTest.php @@ -4,74 +4,59 @@ 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 - */ - 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()); } /** * @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'); $end = new \DateTime('yesterday'); - $this->object->setStart($start); - $this->object->setEnd($end); + $object->setStart($start); + $object->setEnd($end); } /** * @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'); - $this->object->setEnd($end); + $object->setEnd($end); } } 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..c288b1a 100644 --- a/tests/Model/Recurrence/RecurrenceRuleTest.php +++ b/tests/Model/Recurrence/RecurrenceRuleTest.php @@ -8,38 +8,18 @@ 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 - */ - 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) @@ -50,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) @@ -65,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()); } /** @@ -74,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 ae077be..22cd146 100644 --- a/tests/Model/Relationship/AttendeeTest.php +++ b/tests/Model/Relationship/AttendeeTest.php @@ -4,38 +4,18 @@ 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 - */ - 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') @@ -51,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 f030595..bd4eb9e 100644 --- a/tests/Model/Relationship/OrganizerTest.php +++ b/tests/Model/Relationship/OrganizerTest.php @@ -4,38 +4,18 @@ 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 - */ - 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') @@ -44,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()); } } diff --git a/tests/Utility/FormatterTest.php b/tests/Utility/FormatterTest.php index 122cc76..3d77e5f 100644 --- a/tests/Utility/FormatterTest.php +++ b/tests/Utility/FormatterTest.php @@ -4,8 +4,9 @@ use Jsvrcek\ICS\Model\Description\Conference; 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