generated from ergebnis/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6662af2
commit ed520d6
Showing
4 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2020-2022 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/license | ||
*/ | ||
|
||
namespace Ergebnis\License\Type; | ||
|
||
use Ergebnis\License\Header; | ||
use Ergebnis\License\Holder; | ||
use Ergebnis\License\Period; | ||
use Ergebnis\License\Template; | ||
use Ergebnis\License\Url; | ||
|
||
final class None | ||
{ | ||
private Header $header; | ||
|
||
private function __construct( | ||
Template $headerTemplate, | ||
Period $period, | ||
Holder $holder, | ||
Url $url | ||
) { | ||
$header = Header::createWithoutReferenceToLicenseFile( | ||
$headerTemplate, | ||
$period, | ||
$holder, | ||
$url, | ||
); | ||
|
||
$this->header = $header; | ||
} | ||
|
||
public static function text( | ||
Period $period, | ||
Holder $holder, | ||
Url $url | ||
): self { | ||
return new self( | ||
Template::fromFile(__DIR__ . '/../../resource/header/without-reference-to-license-file.txt'), | ||
$period, | ||
$holder, | ||
$url, | ||
); | ||
} | ||
|
||
public function header(): string | ||
{ | ||
return $this->header->toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2020-2022 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/license | ||
*/ | ||
|
||
namespace Ergebnis\License\Test\Unit\Type; | ||
|
||
use Ergebnis\License\Holder; | ||
use Ergebnis\License\Range; | ||
use Ergebnis\License\Test; | ||
use Ergebnis\License\Type; | ||
use Ergebnis\License\Url; | ||
use Ergebnis\License\Year; | ||
use PHPUnit\Framework; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @covers \Ergebnis\License\Type\None | ||
* | ||
* @uses \Ergebnis\License\Header | ||
* @uses \Ergebnis\License\Holder | ||
* @uses \Ergebnis\License\Range | ||
* @uses \Ergebnis\License\Template | ||
* @uses \Ergebnis\License\Url | ||
* @uses \Ergebnis\License\Year | ||
*/ | ||
final class NoneTest extends Framework\TestCase | ||
{ | ||
use Test\Util\Helper; | ||
|
||
public function testHeaderReturnsHeaderForTextLicense(): void | ||
{ | ||
$faker = self::faker(); | ||
|
||
$range = Range::since( | ||
Year::fromString($faker->year()), | ||
new \DateTimeZone($faker->timezone()), | ||
); | ||
$holder = Holder::fromString($faker->name()); | ||
$url = Url::fromString($faker->url()); | ||
|
||
$license = Type\None::text( | ||
$range, | ||
$holder, | ||
$url, | ||
); | ||
|
||
$expected = <<<TXT | ||
Copyright (c) {$range->toString()} {$holder->toString()} | ||
@see {$url->toString()} | ||
TXT; | ||
|
||
self::assertSame($expected, $license->header()); | ||
} | ||
} |