Skip to content

Commit

Permalink
Improve readability of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spekulatius committed Nov 10, 2022
1 parent e0a9106 commit 3227437
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tests/BaseHrefTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testMissingBaseHref()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// Check the baseHref as not given (null)
$this->assertSame(null, $web->baseHref);
$this->assertNull($web->baseHref);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/CanonicalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testMissingCanonical()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// null if there isn't a canonical set.
$this->assertSame(null, $web->canonical);
$this->assertNull($web->canonical);
}

/**
Expand Down
25 changes: 20 additions & 5 deletions tests/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,34 @@ public function testChangeOfCurrentPage()
$web->go('https://test-pages.phpscraper.de/meta/lorem-ipsum.html');

// Both the method call as well as property call should return the same...
$this->assertSame('https://test-pages.phpscraper.de/meta/lorem-ipsum.html', $web->currentUrl);
$this->assertSame('Lorem Ipsum', $web->title);
$this->assertSame(
'https://test-pages.phpscraper.de/meta/lorem-ipsum.html',
$web->currentUrl
);
$this->assertSame(
'Lorem Ipsum',
$web->title
);


// 2. Leave the current page and head on to the next one.
$web->go('https://phpscraper.de');

// We should have navigated.
$this->assertSame('https://phpscraper.de', $web->currentUrl);
$this->assertSame(
'https://phpscraper.de',
$web->currentUrl
);

// Shouldn't match, because we surfed on...
$this->assertNotSame('https://test-pages.phpscraper.de/meta/lorem-ipsum.html', $web->currentUrl);
$this->assertNotSame('Lorem Ipsum', $web->title);
$this->assertNotSame(
'https://test-pages.phpscraper.de/meta/lorem-ipsum.html',
$web->currentUrl
);
$this->assertNotSame(
'Lorem Ipsum',
$web->title
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaAuthorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testMissingAuthor()
$web->go('https://test-pages.phpscraper.de/meta/meta/missing.html');

// Check the author as not given (null)
$this->assertSame(null, $web->author);
$this->assertNull($web->author);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaContentTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testMissingCharset()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// Check the contentType as not given (null)
$this->assertSame(null, $web->contentType);
$this->assertNull($web->contentType);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaCsrfTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testMissingCsrfToken()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// Check the csrfToken as not given (null)
$this->assertSame(null, $web->csrfToken);
$this->assertNull($web->csrfToken);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testMissingDescription()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// Check the description as not given (null)
$this->assertSame(null, $web->description);
$this->assertNull($web->description);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testMissingImage()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// Check the absolute image path
$this->assertSame(null, $web->image);
$this->assertNull($web->image);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaKeywordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testMissingKeywords()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// null if there aren't any keywords set.
$this->assertSame(null, $web->keywordString);
$this->assertNull($web->keywordString);

// Empty array if there aren't any keywords set.
$this->assertTrue(is_iterable($web->keywords));
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaViewportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testMissingViewport()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// null if there isn't a viewport set.
$this->assertSame(null, $web->viewportString);
$this->assertNull($web->viewportString);

// Empty array if there aren't any viewports set.
$this->assertTrue(is_iterable($web->viewport));
Expand Down
27 changes: 21 additions & 6 deletions tests/TitleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testMissingTitle()
$web->go('https://test-pages.phpscraper.de/meta/missing.html');

// Check the title as not given (null)
$this->assertSame(null, $web->title);
$this->assertNull($web->title);
}

/**
Expand All @@ -29,7 +29,10 @@ public function testWithHTMLEntity()
$web->go('https://test-pages.phpscraper.de/meta/html-entities.html');

// Check the title
$this->assertSame('Cat & Mouse', $web->title);
$this->assertSame(
'Cat & Mouse',
$web->title
);
}

/**
Expand All @@ -43,7 +46,10 @@ public function testLoremIpsum()
$web->go('https://test-pages.phpscraper.de/meta/lorem-ipsum.html');

// Check the title
$this->assertSame('Lorem Ipsum', $web->title);
$this->assertSame(
'Lorem Ipsum',
$web->title
);
}

/**
Expand All @@ -57,7 +63,10 @@ public function testGermanUmlaute()
$web->go('https://test-pages.phpscraper.de/meta/german-umlaute.html');

// Check the title
$this->assertSame('A page with plenty of German umlaute everywhere (ä ü ö)', $web->title);
$this->assertSame(
'A page with plenty of German umlaute everywhere (ä ü ö)',
$web->title
);
}

/**
Expand All @@ -71,7 +80,10 @@ public function testChineseCharacters()
$web->go('https://test-pages.phpscraper.de/meta/chinese-characters.html');

// Check the title
$this->assertSame('Page with Chinese Characters all over the place (加油)', $web->title);
$this->assertSame(
'Page with Chinese Characters all over the place (加油)',
$web->title
);
}

/**
Expand All @@ -85,6 +97,9 @@ public function testLongTitle()
$web->go('https://test-pages.phpscraper.de/title/long-title.html');

// Check the title
$this->assertSame('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis purus id ex consectetur facilisis. In gravida sodales nisl a consequat. Aenean ipsum sem, congue et rhoncus a, feugiat eget enim. Duis ut malesuada neque. Nam justo est, interdum eu massa in, volutpat vestibulum libero. Mauris a varius mauris, in vulputate ligula. Nulla rhoncus eget purus a sodales. Nulla facilisi. Proin purus purus, sodales non dolor in, lobortis elementum augue. Nulla sagittis, ex eu placerat varius, nulla mi rutrum odio, sit amet lacinia ipsum urna nec massa. Quisque posuere mauris id condimentum viverra.', $web->title);
$this->assertSame(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis purus id ex consectetur facilisis. In gravida sodales nisl a consequat. Aenean ipsum sem, congue et rhoncus a, feugiat eget enim. Duis ut malesuada neque. Nam justo est, interdum eu massa in, volutpat vestibulum libero. Mauris a varius mauris, in vulputate ligula. Nulla rhoncus eget purus a sodales. Nulla facilisi. Proin purus purus, sodales non dolor in, lobortis elementum augue. Nulla sagittis, ex eu placerat varius, nulla mi rutrum odio, sit amet lacinia ipsum urna nec massa. Quisque posuere mauris id condimentum viverra.',
$web->title
);
}
}

0 comments on commit 3227437

Please sign in to comment.