Skip to content

Commit

Permalink
Merge branch 'php8'
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Svrcek authored and Justin Svrcek committed Jan 12, 2021
2 parents e222564 + 68d2ff2 commit fce6d1f
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 132 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0

sudo: false

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion tests/CalendarExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/CalendarStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
53 changes: 19 additions & 34 deletions tests/Model/CalendarEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
3 changes: 2 additions & 1 deletion tests/Model/CalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 18 additions & 39 deletions tests/Model/Recurrence/RecurrenceRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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());
}

/**
Expand All @@ -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());
*/
}
}
32 changes: 6 additions & 26 deletions tests/Model/Relationship/AttendeeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('[email protected]')
->setName('Joe Smith')
->setCalendarUserType('INDIVIDUAL')
Expand All @@ -51,6 +31,6 @@ public function testToString()

$expected = 'ATTENDEE;CUTYPE=INDIVIDUAL;MEMBER="mailto:[email protected]";ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE;DELEGATED-TO="mailto:[email protected]","mailto:[email protected]";DELEGATED-FROM="mailto:[email protected]";SENT-BY="[email protected]";CN=Joe Smith;LANGUAGE=en:mailto:[email protected]';

$this->assertEquals($expected, $this->object->__toString());
$this->assertEquals($expected, $object->__toString());
}
}
32 changes: 6 additions & 26 deletions tests/Model/Relationship/OrganizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('[email protected]')
->setName('Leonardo Da Vinci')
->setLanguage('it')
Expand All @@ -44,6 +24,6 @@ public function testToString()

$expected = 'ORGANIZER;SENT-BY="[email protected]";CN=Leonardo Da Vinci;DIR="http://en.wikipedia.org/wiki/Leonardo_da_Vinci";LANGUAGE=it:mailto:[email protected]';

$this->assertEquals($expected, $this->object->__toString());
$this->assertEquals($expected, $object->__toString());
}
}
3 changes: 2 additions & 1 deletion tests/Utility/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/Utility/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fce6d1f

Please sign in to comment.