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

0.x support 8.1 #425

Merged
merged 3 commits into from
Jun 18, 2022
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
8 changes: 2 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ jobs:
strategy:
matrix:
php-version:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
# I am to lazy to fix the CI now, because we will update PHPUnit and drop some PHP versions later,
# then this version will be activate again and everything should work...
# - "8.0"
- "8.0"
- "8.1"
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.php_cs.cache
.phpunit.result.cache
/composer.lock
/vendor
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- Support PHP 8.1
### Changed
- Use PHPUnit v9.5
### Removed
- Support for EOL PHP versions (7.1, 7.2, 7.3)

## [0.16.1]
### Added
- Support PHP 8.0 [#194](https://github.com/markuspoerschke/iCal/pull/194)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
}
},
"require": {
"php": ">=7.1 || ~8.0.0"
"php": ">=7.4"
},
"suggest": {
"ext-mbstring" : "Massive performance enhancement of line folding"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
"phpunit/phpunit": "^9.5"
},
"scripts": {
"test": "phpunit"
Expand Down
24 changes: 13 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./vendor/autoload.php">
<logging>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true" showOnlySummary="true"/>
</logging>
bootstrap="./vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<text outputFile="php://stdout" showUncoveredFiles="true" showOnlySummary="true"/>
</report>
</coverage>
<logging/>
<testsuites>
<testsuite name="eluceo iCal Test Suite">
<directory suffix="Test.php">./tests/Eluceo/iCal/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
10 changes: 7 additions & 3 deletions src/Property/Event/RecurrenceRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,13 @@ public function getUntil()
*/
public function setFreq($freq)
{
if (@constant('static::FREQ_' . $freq) !== null) {
$this->freq = $freq;
} else {
try {
if (@constant('static::FREQ_' . $freq) !== null) {
$this->freq = $freq;
} else {
throw new \InvalidArgumentException("The Frequency {$freq} is not supported.");
}
} catch (\Error $error) {
throw new \InvalidArgumentException("The Frequency {$freq} is not supported.");
}

Expand Down
2 changes: 1 addition & 1 deletion src/PropertyBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function add(Property $property)
return $this;
}

public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayObject($this->elements);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Eluceo/iCal/Component/CalendarIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testExample3()
{
$this->assertTrue(isset($lines[$key]), 'Too many lines... ' . $line);

$this->assertRegExp($lines[$key], $line);
$this->assertMatchesRegularExpression($lines[$key], $line);
}
}

Expand Down Expand Up @@ -116,7 +116,7 @@ public function testExample4b()
{
$this->assertTrue(isset($lines[$key]), 'Too many lines... ' . $line);

$this->assertRegExp($lines[$key], $line);
$this->assertMatchesRegularExpression($lines[$key], $line);
}
}

Expand Down Expand Up @@ -191,7 +191,7 @@ public function testEventAddAttachment()
{
$this->assertTrue(isset($lines[$key]), 'Too many lines... ' . $line);

$this->assertRegExp($lines[$key], $line);
$this->assertMatchesRegularExpression($lines[$key], $line);
}
}
}
9 changes: 4 additions & 5 deletions tests/Eluceo/iCal/Component/CalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

class CalendarTest extends TestCase
{
/**
* @expectedException \UnexpectedValueException
* @expectedExceptionMessage PRODID cannot be empty
*/
public function testConstructorThrowsUnexpectedValueException()
{
$this->expectExceptionMessage("PRODID cannot be empty");
$this->expectException(\UnexpectedValueException::class);

new Calendar(null);
}

Expand Down Expand Up @@ -108,6 +107,6 @@ public function testAddEvent()
$calendar = new Calendar('-//ABC Corporation//NONSGML My Product//EN');
$calendar->addEvent(new Event('unique_id'));

$this->assertContains("unique_id", $calendar->render());
$this->assertStringContainsString("unique_id", $calendar->render());
}
}
7 changes: 3 additions & 4 deletions tests/Eluceo/iCal/Component/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ public function testSetLocation()
$this->assertSame('LOCATION:Conference Room - F123\, Bldg. 002', $result['LOCATION']->toLine());
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The parameter 'geo' must be a string or an instance of Eluceo\iCal\Property\Event\Geo but an instance of ArrayObject was given.
*/
public function testSetLocationOnInvalidGeo()
{
$this->expectExceptionMessage("The parameter 'geo' must be a string or an instance of Eluceo\iCal\Property\Event\Geo but an instance of ArrayObject was given.");
$this->expectException(\InvalidArgumentException::class);

$event = new Event('[email protected]');
$event->setLocation('Conference Room - F123, Bldg. 002', '', new \ArrayObject([25.632, 122.072]));
$result = $event->buildPropertyBag()->getIterator()->getArrayCopy();
Expand Down
10 changes: 5 additions & 5 deletions tests/Eluceo/iCal/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testFoldWithMultibyte()

$output = $vCalendar->render();
$output = preg_replace('/\r\n /u', '', $output);
$this->assertContains($input, $output);
$this->assertStringContainsString($input, $output);
}

public function testDescriptionWithNewLines()
Expand All @@ -42,7 +42,7 @@ public function testDescriptionWithNewLines()
$vCalendar->addComponent($vEvent);

$output = $vCalendar->render();
$this->assertContains(str_replace("\n", "\\n", $input), $output);
$this->assertStringContainsString(str_replace("\n", "\\n", $input), $output);
}

public function testAddComponentOnKey()
Expand All @@ -58,7 +58,7 @@ public function testAddComponentOnKey()
$vCalendar->addComponent($vEvent, 'eventKey');

$output = $vCalendar->render();
$this->assertContains(str_replace("\n", "\\n", $input), $output);
$this->assertStringContainsString(str_replace("\n", "\\n", $input), $output);
}

public function testSetComponents()
Expand All @@ -80,8 +80,8 @@ public function testSetComponents()
$vCalendar->setComponents([$vEventTwo]);

$output = $vCalendar->render();
$this->assertContains($shouldBeFound, $output);
$this->assertNotContains($shouldNotBeFound, $output);
$this->assertStringContainsString($shouldBeFound, $output);
$this->assertStringNotContainsString($shouldNotBeFound, $output);
}

public function testToString()
Expand Down
14 changes: 6 additions & 8 deletions tests/Eluceo/iCal/Property/Event/AttendeesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@ public function testGetValue()
$this->assertCount(0, $attendees->getValue());
}

/**
* @expectedException \BadMethodCallException
* @expectedExceptionMessage Cannot call setParam on Attendees Property
*/
public function testSetParamThrowsBadMethodCallException()
{
$this->expectExceptionMessage("Cannot call setParam on Attendees Property");
$this->expectException(\BadMethodCallException::class);

$attendees = new Attendees();
$attendees->setParam('MAILTO', '[email protected]');
}

/**
* @expectedException \BadMethodCallException
* @expectedExceptionMessage Cannot call getParam on Attendees Property
*/
public function testGetParamThrowsBadMethodCallException()
{
$this->expectExceptionMessage("Cannot call getParam on Attendees Property");
$this->expectException(\BadMethodCallException::class);

$attendees = new Attendees();
$attendees->getParam('MAILTO');
}
Expand Down
14 changes: 6 additions & 8 deletions tests/Eluceo/iCal/Property/Event/GeoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ public function testConstructor()
$this->assertInstanceOf(Geo::class, $geo);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The geographical latitude must be a value between -90 and 90 degrees. '-100' was given.
*/
public function testConstructorOnInvalidLatitude()
{
$this->expectExceptionMessage("The geographical latitude must be a value between -90 and 90 degrees. '-100' was given.");
$this->expectException(\InvalidArgumentException::class);

new Geo(-100, 122.072);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The geographical longitude must be a value between -180 and 180 degrees. '-200' was given.
*/
public function testConstructorOnInvalidLongitude()
{
$this->expectExceptionMessage("The geographical longitude must be a value between -180 and 180 degrees. '-200' was given.");
$this->expectException(\InvalidArgumentException::class);

new Geo(25.632, -200);
}

Expand Down
19 changes: 9 additions & 10 deletions tests/Eluceo/iCal/Property/Event/RecurrenceIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RecurrenceIdTest extends TestCase
{
public function testConstructorOnDateTime()
{
$this->assertInstanceOf(RecurrenceId::class, new RecurrenceId(new \DateTime(null, new \DateTimeZone('Asia/Taipei'))));
$this->assertInstanceOf(RecurrenceId::class, new RecurrenceId(new \DateTime('now', new \DateTimeZone('Asia/Taipei'))));
}

public function testConstructorOnNullDateTime()
Expand All @@ -21,7 +21,7 @@ public function testApplyTimeSettings()
$recurrenceId = new RecurrenceId();
$recurrenceId->applyTimeSettings();

$this->assertContains(date('Ymd'), $recurrenceId->getValue()->getValue());
$this->assertStringContainsString(date('Ymd'), $recurrenceId->getValue()->getValue());
}

public function testApplyTimeSettingsOnRange()
Expand All @@ -30,21 +30,21 @@ public function testApplyTimeSettingsOnRange()
$recurrenceId->setRange('RANGE=THISANDPRIOR:19980401T133000Z');
$recurrenceId->applyTimeSettings();

$this->assertContains(date('Ymd'), $recurrenceId->getValue()->getValue());
$this->assertStringContainsString(date('Ymd'), $recurrenceId->getValue()->getValue());
}

public function testApplyTimeSettingsOnDefaultParams()
{
$recurrenceId = new RecurrenceId();
$recurrenceId->applyTimeSettings(true, true, true, 'Europe/Berlin');

$this->assertContains(date('Ymd'), $recurrenceId->getValue()->getValue());
$this->assertStringContainsString(date('Ymd'), $recurrenceId->getValue()->getValue());
$this->assertSame(date('Ymd'), $recurrenceId->getValue()->getValue());
}

public function testGetDatetime()
{
$recurrenceId = new RecurrenceId(new \DateTime(null, new \DateTimeZone('Europe/Berlin')));
$recurrenceId = new RecurrenceId(new \DateTime('now', new \DateTimeZone('Europe/Berlin')));

$this->assertInstanceOf(\DateTime::class, $recurrenceId->getDatetime());
$this->assertSame('Europe/Berlin', $recurrenceId->getDatetime()->getTimeZone()->getName());
Expand All @@ -53,7 +53,7 @@ public function testGetDatetime()
public function testSetDatetime()
{
$recurrenceId = new RecurrenceId();
$recurrenceId->setDatetime(new \DateTime(null, new \DateTimeZone('Asia/Taipei')));
$recurrenceId->setDatetime(new \DateTime('now', new \DateTimeZone('Asia/Taipei')));

$this->assertInstanceOf(\DateTime::class, $recurrenceId->getDatetime());
$this->assertSame('Asia/Taipei', $recurrenceId->getDatetime()->getTimeZone()->getName());
Expand Down Expand Up @@ -82,12 +82,11 @@ public function testToLines()
$this->assertSame(['RECURRENCE-ID:value1'], $recurrenceId->toLines());
}

/**
* @expectedException \Exception
* @expectedExceptionMessage The value must implement the ValueInterface.
*/
public function testToLinesThrowsException()
{
$this->expectExceptionMessage("The value must implement the ValueInterface.");
$this->expectException(\Exception::class);

$recurrenceId = new RecurrenceId();

$recurrenceId->toLines();
Expand Down
Loading