Skip to content
Open
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
],
"require": {
"php": "~7.1",
"symfony/property-access": "~3.0|^4.0",
"symfony/property-access": "^3.0|^4.0|^5.0",
"nikic/iter": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"symfony/routing": "^3.0|^4.0",
"symfony/routing": "^3.0|^4.0|^5.0",
"friendsofphp/php-cs-fixer": "^2.10",
"kphoen/rusty": "dev-master"
},
Expand Down
15 changes: 7 additions & 8 deletions tests/Dumper/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,31 @@ protected function createDumper()
return new File($this->dummyFile());
}

public function testDumper()
public function testDumper(): void
{
$this->dumper->dump('joe');
$this->assertTrue(file_exists($this->dummyFile()));
$this->assertFileExists($this->dummyFile());

$this->assertSame('joe', file_get_contents($this->dummyFile()));

$this->dumper->dump('-hell yeah!');
$this->assertSame('joe-hell yeah!', file_get_contents($this->dummyFile()));
}

/**
* @expectedException \RuntimeException
*/
public function testAnExceptionIsThrownForNonWriteableFiles()
public function testAnExceptionIsThrownForNonWriteableFiles(): void
{
$this->expectException(\RuntimeException::class);

$dumper = new File($this->nonWriteableFile());
$dumper->dump('foo');
}

public function testCurrentFilenameIsAccessible()
public function testCurrentFilenameIsAccessible(): void
{
$this->assertSame($this->dummyFile(), $this->dumper->getFilename());
}

public function testFilenameCanBeChanged()
public function testFilenameCanBeChanged(): void
{
$newDumper = $this->dumper->changeFile($this->otherDummyFile());

Expand Down
4 changes: 2 additions & 2 deletions tests/Dumper/FileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class FileTestCase extends TestCase

abstract protected function createDumper();

public function setUp()
public function setUp(): void
{
$this->file = sys_get_temp_dir() . '/dummy_file';
$this->otherFile = sys_get_temp_dir() . '/other_file';
Expand All @@ -26,7 +26,7 @@ public function setUp()
$this->dumper = $this->createDumper();
}

public function tearDown()
public function tearDown(): void
{
file_exists($this->file) && unlink($this->file);
file_exists($this->otherFile) && unlink($this->otherFile);
Expand Down
4 changes: 2 additions & 2 deletions tests/Dumper/GzFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ protected function createDumper()
return new GzFile($this->dummyFile());
}

public function testDumper()
public function testDumper(): void
{
$this->dumper->dump('joe');
$this->dumper->dump('-hell yeah!');

$this->assertTrue(file_exists($this->dummyFile()));
$this->assertFileExists($this->dummyFile());
unset($this->dumper); // force the dumper to close the file

$this->assertSame('joe-hell yeah!', file_get_contents('compress.zlib://' . $this->dummyFile()));
Expand Down
2 changes: 1 addition & 1 deletion tests/Dumper/MemoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MemoryTest extends TestCase
{
public function testDumper()
public function testDumper(): void
{
$dumper = new Memory();
$this->assertSame('foo', $dumper->dump('foo'));
Expand Down
11 changes: 5 additions & 6 deletions tests/Entity/SitemapIndexEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@

class SitemapIndexEntryTest extends TestCase
{
/**
* @expectedException \DomainException
*/
public function testLocMaxLength()
public function testLocMaxLength(): void
{
$this->expectException(\DomainException::class);

new SitemapIndexEntry('http://google.fr/?q=' . str_repeat('o', 2048));
}

public function testConstructionWithASingleArgument()
public function testConstructionWithASingleArgument(): void
{
$entry = new SitemapIndexEntry('http://google.fr/');

$this->assertSame('http://google.fr/', $entry->getLoc());
$this->assertNull($entry->getLastmod());
}

public function testConstructionWithAllTheArguments()
public function testConstructionWithAllTheArguments(): void
{
$entry = new SitemapIndexEntry('http://google.fr/', \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2016-02-28 14:34:25', new \DateTimeZone('Europe/Paris')));

Expand Down
27 changes: 13 additions & 14 deletions tests/Entity/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,36 @@

class UrlTest extends TestCase
{
/**
* @expectedException \DomainException
*/
public function testLocMaxLength()
public function testLocMaxLength(): void
{
$this->expectException(\DomainException::class);

new Url('http://google.fr/?q=' . str_repeat('o', 2048));
}

/**
* @dataProvider invalidPriorityProvider
* @expectedException \DomainException
*/
public function testInvalidPriority($priority)
public function testInvalidPriority($priority): void
{
$this->expectException(\DomainException::class);

$url = new Url('http://www.google.fr/');
$url->setPriority($priority);
}

/**
* @expectedException \DomainException
*/
public function testInvalidChangefreq()
public function testInvalidChangefreq(): void
{
$this->expectException(\DomainException::class);

$url = new Url('http://www.google.fr/');
$url->setChangeFreq('foo');
}

/**
* @dataProvider changefreqProvider
*/
public function testChangefreq($changefreq)
public function testChangefreq($changefreq): void
{
$url = new Url('http://www.google.fr/');
$url->setChangeFreq($changefreq);
Expand All @@ -51,7 +50,7 @@ public function testChangefreq($changefreq)
/**
* @dataProvider lastmodProvider
*/
public function testLastmodFormatting($lastmod, $changefreq, $expectedLastmod)
public function testLastmodFormatting($lastmod, $changefreq, $expectedLastmod): void
{
$url = new Url('http://www.google.fr/');
$url->setLastmod($lastmod);
Expand All @@ -60,7 +59,7 @@ public function testLastmodFormatting($lastmod, $changefreq, $expectedLastmod)
$this->assertSame($expectedLastmod, $url->getLastmod());
}

public function testImages()
public function testImages(): void
{
$url = new Url('http://www.google.fr/');
$image = new Image('https://www.google.fr/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png');
Expand All @@ -70,7 +69,7 @@ public function testImages()
$this->assertSame([$image], $url->getImages());
}

public function testVideos()
public function testVideos(): void
{
$url = new Url('http://www.google.fr/');
$video = new Video('Title', 'Description.', 'https://thumbnail.loc/img.jpg');
Expand Down
70 changes: 32 additions & 38 deletions tests/Entity/VideoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@

class VideoTest extends TestCase
{
/**
* @expectedException \DomainException
*/
public function testTitleMaxLength()
public function testTitleMaxLength(): void
{
$this->expectException(\DomainException::class);

new Video(str_repeat('o', 100), 'Description.', 'https://thumbnail.loc/img.jpg');
$this->assertTrue(true);

new Video(str_repeat('o', 101), 'Description.', 'https://thumbnail.loc/img.jpg');
}

/**
* @expectedException \DomainException
*/
public function testDescriptionMaxLength()
public function testDescriptionMaxLength(): void
{
$this->expectException(\DomainException::class);

new Video('title', str_repeat('o', 2048), 'https://thumbnail.loc/img.jpg');
$this->assertTrue(true);

Expand All @@ -31,18 +29,19 @@ public function testDescriptionMaxLength()

/**
* @dataProvider invalidDurationProvider
* @expectedException \DomainException
*/
public function testInvalidDuration($duration)
public function testInvalidDuration($duration): void
{
$this->expectException(\DomainException::class);

$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setDuration($duration);
}

/**
* @dataProvider dateProvider
*/
public function testExpirationDate($date, $expectedDate)
public function testExpirationDate($date, $expectedDate): void
{
$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setExpirationDate($date);
Expand All @@ -52,7 +51,7 @@ public function testExpirationDate($date, $expectedDate)
/**
* @dataProvider dateProvider
*/
public function testPublicationDate($date, $expectedDate)
public function testPublicationDate($date, $expectedDate): void
{
$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setPublicationDate($date);
Expand All @@ -61,67 +60,62 @@ public function testPublicationDate($date, $expectedDate)

/**
* @dataProvider invalidRatingProvider
* @expectedException \DomainException
*/
public function testInvalidRating($rating)
public function testInvalidRating($rating): void
{
$this->expectException(\DomainException::class);

$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setRating($rating);
}

/**
* @expectedException \DomainException
*/
public function testInvalidViewCount()
public function testInvalidViewCount(): void
{
$this->expectException(\DomainException::class);

$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setViewCount(-1);
}

/**
* @expectedException \DomainException
*/
public function testInvalidTagsCount()
public function testInvalidTagsCount(): void
{
$this->expectException(\DomainException::class);

$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setTags(array_pad([], 33, 'tag'));
}

/**
* @expectedException \DomainException
*/
public function testCategoryMaxLength()
public function testCategoryMaxLength(): void
{
$this->expectException(\DomainException::class);

$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setCategory(str_repeat('o', 256));
$this->assertTrue(true);

$video->setCategory(str_repeat('o', 257));
}

/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidRestriction()
public function testInvalidRestriction(): void
{
$this->expectException(\InvalidArgumentException::class);

$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setRestrictions(['fr', 'en'], 'foo');
}

/**
* @expectedException \DomainException
*/
public function testInvalidPlatform()
public function testInvalidPlatform(): void
{
$this->expectException(\DomainException::class);

$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setPlatforms([Video::PLATFORM_TV => Video::RESTRICTION_DENY, 'foo' => Video::RESTRICTION_DENY]);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidPlatformRelationship()
public function testInvalidPlatformRelationship(): void
{
$this->expectException(\InvalidArgumentException::class);

$video = new Video('title', 'Description', 'https://thumbnail.loc/img.jpg');
$video->setPlatforms([Video::PLATFORM_TV => Video::RESTRICTION_DENY, Video::PLATFORM_MOBILE => 'foo']);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Formatter/RichXmlFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

class RichXmlFormatterTest extends XmlFormatterTest
{
protected function setUp()
protected function setUp(): void
{
$this->formatter = new Formatter\RichXml();
}

public function testSitemapStart()
public function testSitemapStart(): void
{
$this->assertSame('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n", $this->formatter->getSitemapStart());
}

public function testFormatRichUrl()
public function testFormatRichUrl(): void
{
$url = new RichUrl('http://www.google.fr');
$url->setPriority(0.2);
Expand Down
Loading