Skip to content

Commit

Permalink
Merge branch 'hotfix/21'
Browse files Browse the repository at this point in the history
Close #21
  • Loading branch information
michalbundyra committed Aug 18, 2020
2 parents f14796a + c789219 commit 3c91415
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.coveralls.yml export-ignore
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/docs/ export-ignore
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
repository_dispatch:
types: docs-build

jobs:
build-deploy:
Expand Down
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.12.2 - TBD
## 2.12.3 - 2020-08-18

### Added

Expand All @@ -22,8 +22,31 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- [#21](https://github.com/laminas/laminas-feed/pull/21) fixes the writer extension
of iTunes to support valid values for the `itunes:explicit` element.

## 2.12.2 - 2020-03-29

### Added

- Nothing.

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Fixed `replace` version constraint in composer.json so repository can be used as replacement of `zendframework/zend-feed:^2.12.0`.

## 2.12.1 - 2020-03-23

### Added
Expand Down
3 changes: 1 addition & 2 deletions COPYRIGHT.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Copyright (c) 2019-2020, Laminas Foundation.
All rights reserved. (https://getlaminas.org/)
Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC. (https://getlaminas.org/)
3 changes: 1 addition & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Copyright (c) 2019-2020, Laminas Foundation
All rights reserved.
Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
},
"replace": {
"zendframework/zend-feed": "self.version"
"zendframework/zend-feed": "^2.12.0"
}
}
21 changes: 18 additions & 3 deletions src/Writer/Extension/ITunes/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,33 @@ public function setItunesDuration($value)
/**
* Set "explicit" flag
*
* @see https://help.apple.com/itc/podcasts_connect/#/itcb54353390
*
* @param bool $value
* @return $this
* @throws Writer\Exception\InvalidArgumentException
*/
public function setItunesExplicit($value)
{
if (! in_array($value, ['yes', 'no', 'clean'])) {
// "yes", "no" and "clean" are valid values for a previous version
if (! is_bool($value) && ! in_array($value, ['yes', 'no', 'clean'])) {
throw new Writer\Exception\InvalidArgumentException(
'invalid parameter: "explicit" may only be one of "yes", "no" or "clean"'
'invalid parameter: "explicit" must be a boolean value'
);
}
$this->data['explicit'] = $value;

switch ($value) {
case 'yes':
$value = true;
break;

case 'no':
case 'clean':
$value = false;
break;
}

$this->data['explicit'] = $value ? 'true' : 'false';
return $this;
}

Expand Down
21 changes: 18 additions & 3 deletions src/Writer/Extension/ITunes/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,33 @@ public function setItunesDuration($value)
/**
* Set "explicit" flag
*
* @see https://help.apple.com/itc/podcasts_connect/#/itcb54353390
*
* @param bool $value
* @return $this
* @throws Writer\Exception\InvalidArgumentException
*/
public function setItunesExplicit($value)
{
if (! in_array($value, ['yes', 'no', 'clean'])) {
// "yes", "no" and "clean" are valid values for a previous version
if (! is_bool($value) && ! in_array($value, ['yes', 'no', 'clean'])) {
throw new Writer\Exception\InvalidArgumentException(
'invalid parameter: "explicit" may only be one of "yes", "no" or "clean"'
'invalid parameter: "explicit" must be a boolean value'
);
}
$this->data['explicit'] = $value;

switch ($value) {
case 'yes':
$value = true;
break;

case 'no':
case 'clean':
$value = false;
break;
}

$this->data['explicit'] = $value ? 'true' : 'false';
return $this;
}

Expand Down
48 changes: 34 additions & 14 deletions test/Writer/Extension/ITunes/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,45 @@ public function testSetDurationThrowsExceptionOnInvalidMinutes()
$entry->setItunesDuration('23:234:45');
}

public function testSetExplicitToYes()
{
$entry = new Writer\Entry();
$entry->setItunesExplicit('yes');
$this->assertEquals('yes', $entry->getItunesExplicit());
}

public function testSetExplicitToNo()
/**
* @dataProvider dataProviderForSetExplicit
*
* @param string|bool $value
* @param string $result
*/
public function testSetExplicit($value, $result)
{
$entry = new Writer\Entry();
$entry->setItunesExplicit('no');
$this->assertEquals('no', $entry->getItunesExplicit());
$entry->setItunesExplicit($value);
$this->assertEquals($result, $entry->getItunesExplicit());
}

public function testSetExplicitToClean()
public function dataProviderForSetExplicit()
{
$entry = new Writer\Entry();
$entry->setItunesExplicit('clean');
$this->assertEquals('clean', $entry->getItunesExplicit());
return [
// Current behaviour
[
true,
'true',
],
[
false,
'false',
],
// Old behaviour
[
'yes',
'true',
],
[
'no',
'false',
],
[
'clean',
'false',
],
];
}

public function testSetExplicitThrowsExceptionOnUnknownTerm()
Expand Down
48 changes: 34 additions & 14 deletions test/Writer/Extension/ITunes/FeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,45 @@ public function testSetDurationThrowsExceptionOnInvalidMinutes()
$feed->setItunesDuration('23:234:45');
}

public function testSetExplicitToYes()
{
$feed = new Writer\Feed();
$feed->setItunesExplicit('yes');
$this->assertEquals('yes', $feed->getItunesExplicit());
}

public function testSetExplicitToNo()
/**
* @dataProvider dataProviderForSetExplicit
*
* @param string|bool $value
* @param string $result
*/
public function testSetExplicit($value, $result)
{
$feed = new Writer\Feed();
$feed->setItunesExplicit('no');
$this->assertEquals('no', $feed->getItunesExplicit());
$feed->setItunesExplicit($value);
$this->assertEquals($result, $feed->getItunesExplicit());
}

public function testSetExplicitToClean()
public function dataProviderForSetExplicit()
{
$feed = new Writer\Feed();
$feed->setItunesExplicit('clean');
$this->assertEquals('clean', $feed->getItunesExplicit());
return [
// Current behaviour
[
true,
'true',
],
[
false,
'false',
],
// Old behaviour
[
'yes',
'true',
],
[
'no',
'false',
],
[
'clean',
'false',
],
];
}

public function testSetExplicitThrowsExceptionOnUnknownTerm()
Expand Down

0 comments on commit 3c91415

Please sign in to comment.