Skip to content

Commit

Permalink
Merge pull request #168 from spatie/master
Browse files Browse the repository at this point in the history
Dump dev dependencies, update changelog
  • Loading branch information
lptn authored Mar 1, 2023
2 parents eccc260 + 603c030 commit bde9ea3
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@

# All test snapshots and text stubs must have CRLF line endings
tests/**/__snapshots__/IcsGeneratorTest* text eol=crlf

# PHPUnit
.phpunit.cache
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to `calendar-links` will be documented in this file

## 1.8.2 - 2022-12-11
### Changed
- ICS: Use `DESCRIPTION` instead of `X-ALT-DESC` (as it has better support) by @cdubz in #158
- Chore: fix tests, fix and improve CI

## 1.8.1 - 2022-12-01
### Changed
- Remove PHP 7.4 support
- Update dependencies

## 1.8.0 - 2022-08-20
### Changed
- ICS: Add `PRODID` and `DTSTAMP` required parameters to make ICS valid by @makbeta
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/calendar-links.svg?style=flat-square)](https://packagist.org/packages/spatie/calendar-links)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/calendar-links.svg?style=flat-square)](https://packagist.org/packages/spatie/calendar-links)
![Test](https://github.com/spatie/calendar-links/workflows/Test/badge.svg)
[![Test](https://github.com/spatie/calendar-links/workflows/Test/badge.svg)](https://github.com/spatie/calendar-links/actions/workflows/run-tests.yml)
[![Quality Score](https://img.shields.io/scrutinizer/g/spatie/calendar-links.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/calendar-links)
![Type coverage](https://shepherd.dev/github/spatie/calendar-links/coverage.svg)
![Psalm level](https://shepherd.dev/github/spatie/calendar-links/level.svg)
[![Type coverage](https://shepherd.dev/github/spatie/calendar-links/coverage.svg)](https://shepherd.dev/github/spatie/calendar-links)
[![Psalm level](https://shepherd.dev/github/spatie/calendar-links/level.svg)](https://shepherd.dev/github/spatie/calendar-links)


Using this package you can generate links to add events to calendar systems. Here's a quick example:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"php": "^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.13",
"phpunit/phpunit": "^9.5",
"spatie/phpunit-snapshot-assertions": "^4.2",
"vimeo/psalm": "^5.0"
"friendsofphp/php-cs-fixer": "^3.14",
"phpunit/phpunit": "^9.6 || ^10.0",
"spatie/phpunit-snapshot-assertions": "^4.2 || ^5.0",
"vimeo/psalm": "^5.6"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 8 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">
<coverage processUncoveredFiles="true">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
bootstrap="vendor/autoload.php" backupGlobals="false"
colors="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down
36 changes: 36 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.6.0@e784128902dfe01d489c4123d69918a9f3c1eac5">
<file src="src/Generators/BaseOutlook.php">
<PossiblyUndefinedMethod>
<code>setTimezone</code>
<code>setTimezone</code>
</PossiblyUndefinedMethod>
</file>
<file src="src/Generators/Google.php">
<PossiblyUndefinedMethod>
<code>setTimezone</code>
<code>setTimezone</code>
</PossiblyUndefinedMethod>
</file>
<file src="src/Generators/Yahoo.php">
<PossiblyUndefinedMethod>
<code>setTimezone</code>
<code>setTimezone</code>
</PossiblyUndefinedMethod>
</file>
<file src="src/Link.php">
<MissingParamType>
<code>$property</code>
</MissingParamType>
<PossiblyUndefinedMethod>
<code>modify</code>
</PossiblyUndefinedMethod>
<PropertyTypeCoercion>
<code>clone $from</code>
<code>clone $to</code>
</PropertyTypeCoercion>
<UnsafeInstantiation>
<code>new static($title, $from, $to, $allDay)</code>
</UnsafeInstantiation>
</file>
</files>
3 changes: 2 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="4"
errorLevel="2"
findUnusedVariablesAndParams="true"
resolveFromConfigFile="true"
useDocblockPropertyTypes="true"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src"/>
Expand Down
3 changes: 2 additions & 1 deletion src/Generators/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Google implements Generator
{
/** @var string {@see https://www.php.net/manual/en/function.date.php} */
protected $dateFormat = 'Ymd';
/** @var string */
protected $dateTimeFormat = 'Ymd\THis\Z';

/** {@inheritDoc} */
Expand All @@ -24,7 +25,7 @@ public function generate(Link $link): string
$utcEndDateTime = (clone $link->to)->setTimezone(new DateTimeZone('UTC'));
$dateTimeFormat = $link->allDay ? $this->dateFormat : $this->dateTimeFormat;
$url .= '&dates='.$utcStartDateTime->format($dateTimeFormat).'/'.$utcEndDateTime->format($dateTimeFormat);

// Add timezone name if it is specified in both from and to dates and is the same for both
if (
$link->from->getTimezone() && $link->to->getTimezone()
Expand Down
10 changes: 5 additions & 5 deletions src/Generators/Ics.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public function generate(Link $link): string
$dateTimeFormat = $link->allDay ? $this->dateFormat : $this->dateTimeFormat;

if ($link->allDay) {
$url[] = 'DTSTAMP:'.gmdate($dateTimeFormat, $link->from->getTimestamp()).'Z';
$url[] = 'DTSTART:'.gmdate($dateTimeFormat, $link->from->getTimestamp()).'Z';
$url[] = 'DTSTAMP:'.gmdate($dateTimeFormat, $link->from->getTimestamp());
$url[] = 'DTSTART:'.gmdate($dateTimeFormat, $link->from->getTimestamp());
$url[] = 'DURATION:P'.(max(1, $link->from->diff($link->to)->days)).'D';
} else {
$url[] = 'DTSTAMP:'.gmdate($dateTimeFormat, $link->from->getTimestamp()).'Z';
$url[] = 'DTSTART:'.gmdate($dateTimeFormat, $link->from->getTimestamp()).'Z';
$url[] = 'DTEND:'.gmdate($dateTimeFormat, $link->to->getTimestamp()).'Z';
$url[] = 'DTSTAMP:'.gmdate($dateTimeFormat, $link->from->getTimestamp());
$url[] = 'DTSTART:'.gmdate($dateTimeFormat, $link->from->getTimestamp());
$url[] = 'DTEND:'.gmdate($dateTimeFormat, $link->to->getTimestamp());
}

if ($link->description) {
Expand Down
1 change: 1 addition & 0 deletions src/Generators/Yahoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Yahoo implements Generator
{
/** @var string {@see https://www.php.net/manual/en/function.date.php} */
protected $dateFormat = 'Ymd';
/** @var string */
protected $dateTimeFormat = 'Ymd\THis\Z';

/** {@inheritDoc} */
Expand Down
10 changes: 5 additions & 5 deletions tests/Generators/GeneratorTestContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract protected function generator(): Generator;
abstract protected function linkMethodName(): string;

/** @test */
public function it_can_generate_a_short_event_link()
public function it_can_generate_a_short_event_link(): void
{
$this->assertMatchesSnapshot(
$this->generator()->generate($this->createShortEventLink())
Expand All @@ -25,7 +25,7 @@ public function it_can_generate_a_short_event_link()
}

/** @test */
public function it_can_generate_a_single_day_allday_event_link()
public function it_can_generate_a_single_day_allday_event_link(): void
{
$this->assertMatchesSnapshot(
$this->generator()->generate($this->createSingleDayAllDayEventLink())
Expand All @@ -38,7 +38,7 @@ public function it_can_generate_a_single_day_allday_event_link()
}

/** @test */
public function it_can_generate_a_multiple_days_event_link()
public function it_can_generate_a_multiple_days_event_link(): void
{
$this->assertMatchesSnapshot(
$this->generator()->generate($this->createMultipleDaysEventLink())
Expand All @@ -51,7 +51,7 @@ public function it_can_generate_a_multiple_days_event_link()
}

/** @test */
public function it_can_generate_a_multiple_days_event_link_with_allday_flag()
public function it_can_generate_a_multiple_days_event_link_with_allday_flag(): void
{
$this->assertMatchesSnapshot(
$this->generator()->generate($this->createMultipleDaysAllDayEventLink())
Expand All @@ -64,7 +64,7 @@ public function it_can_generate_a_multiple_days_event_link_with_allday_flag()
}

/** @test */
public function it_can_generate_a_description_is_html_code_event_link_with_allday_flag()
public function it_can_generate_a_description_is_html_code_event_link_with_allday_flag(): void
{
$this->assertMatchesSnapshot(
$this->generator()->generate($this->createDescriptionIsHTMLcodeEventLink())
Expand Down
6 changes: 3 additions & 3 deletions tests/Generators/IcsGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ protected function linkMethodName(): string
}

/** @test */
public function it_can_generate_an_ics_link_with_custom_uid()
public function it_can_generate_an_ics_link_with_custom_uid(): void
{
$this->assertMatchesSnapshot(
$this->generator(['UID' => 'random-uid'])->generate($this->createShortEventLink())
);
}

/** @test */
public function it_has_a_product_id()
public function it_has_a_product_id(): void
{
$this->assertMatchesSnapshot(
$this->generator(['PRODID' => 'Spatie calendar-links'])->generate($this->createShortEventLink())
);
}

/** @test */
public function it_has_a_product_dtstamp()
public function it_has_a_product_dtstamp(): void
{
$this->assertMatchesSnapshot(
$this->generator(['DTSTAMP' => '20180201T090000Z'])->generate($this->createShortEventLink())
Expand Down
2 changes: 1 addition & 1 deletion tests/Generators/YahooGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function linkMethodName(): string
}

/** @test */
public function it_can_generate_a_yahoo_link_for_long_multiple_days_event()
public function it_can_generate_a_yahoo_link_for_long_multiple_days_event(): void
{
$link = Link::create(
'Christmas and New Year',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PRODID:Spatie calendar-links
BEGIN:VEVENT
UID:47e044bc36ced4538c62fc17c3ba087b
SUMMARY:Birthday
DTSTAMP:20180201Z
DTSTART:20180201Z
DTSTAMP:20180201
DTSTART:20180201
DURATION:P5D
DESCRIPTION:With balloons\, clowns and stuff\nBring a dog\, bring a frog
LOCATION:Party Lane 1A\, 1337 Funtown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ PRODID:Spatie calendar-links
BEGIN:VEVENT
UID:aaf6b0d9a2c43d4a1c803a8c80793a08
SUMMARY:Birthday
DTSTAMP:20180201Z
DTSTART:20180201Z
DTSTAMP:20180201
DTSTART:20180201
DURATION:P1D
DESCRIPTION:With balloons\, clowns and stuff\nBring a dog\, bring a frog
LOCATION:Party Lane 1A\, 1337 Funtown
Expand Down
18 changes: 9 additions & 9 deletions tests/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
class LinkTest extends TestCase
{
/** @test */
public function it_is_initializable()
public function it_is_initializable(): void
{
$this->assertInstanceOf(Link::class, $this->createShortEventLink());
}

/** @test */
public function it_will_throw_an_exception_when_to_comes_after_from()
public function it_will_throw_an_exception_when_to_comes_after_from(): void
{
$this->expectException(InvalidLink::class);

Expand All @@ -27,37 +27,37 @@ public function it_will_throw_an_exception_when_to_comes_after_from()
}

/** @test */
public function it_has_a_title()
public function it_has_a_title(): void
{
$this->assertEquals('Birthday', $this->createShortEventLink()->title);
}

/** @test */
public function it_has_a_mutable_from_date()
public function it_has_a_mutable_from_date(): void
{
$this->assertEquals(new DateTime('20180201T090000 UTC'), $this->createShortEventLink()->from);
}

/** @test */
public function it_has_a_mutable_to_date()
public function it_has_a_mutable_to_date(): void
{
$this->assertEquals(new DateTime('20180201T180000 UTC'), $this->createShortEventLink()->to);
}

/** @test */
public function it_has_an_immutable_from_date()
public function it_has_an_immutable_from_date(): void
{
$this->assertEquals(new DateTime('20180201T090000 UTC'), $this->createShortEventLink()->from);
}

/** @test */
public function it_has_an_immutable_to_date()
public function it_has_an_immutable_to_date(): void
{
$this->assertEquals(new \DateTimeImmutable('20180201T180000 UTC'), $this->createShortEventLink()->to);
}

/** @test */
public function it_can_have_a_description()
public function it_can_have_a_description(): void
{
$link = $this->createShortEventLink();
$correctDescription = 'With balloons, clowns and stuff
Expand All @@ -66,7 +66,7 @@ public function it_can_have_a_description()
}

/** @test */
public function it_can_have_an_address()
public function it_can_have_an_address(): void
{
$link = $this->createShortEventLink();

Expand Down

0 comments on commit bde9ea3

Please sign in to comment.