Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adambinnersley committed Oct 23, 2020
1 parent 7474d4c commit 67c9417
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
build:
environment:
php: '7.4.0'

tests:
override:
-
command: 'vendor/bin/phpunit --coverage-clover=coverage.xml'
coverage:
file: 'coverage.xml'
format: 'clover'


before_commands:
- "composer install --prefer-source"

tools:
php_code_coverage:
test_command: vendor/bin/phpunit

checks:
php:
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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" forceCoversAnnotation="true" beStrictAboutCoversAnnotation="false" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" verbose="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" forceCoversAnnotation="true" beStrictAboutCoversAnnotation="true" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" convertNoticesToExceptions="false" verbose="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
Expand Down
19 changes: 16 additions & 3 deletions tests/PaginationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ public function tearDown(): void
* @covers Pager\Pagination::buildQueryString
* @covers Pager\Pagination::getLiActiveClass
* @covers Pager\Pagination::getPaginationClass
* @covers Pager\Pagination::getAActiveClass
* @covers Pager\Pagination::getAClass
* @covers Pager\Pagination::getLiClass
* @covers Pager\Pagination::postLinks
* @covers Pager\Pagination::preLinks
* @covers Pager\Pagination::setAActiveClass
* @covers Pager\Pagination::setAClass
* @covers Pager\Pagination::setLiClass
* @covers Pager\Pagination::setPaginationClass
*/
public function testCreatePager()
{
Expand All @@ -37,11 +44,11 @@ public function testCreatePager()
$this->assertStringContainsString('<li class="active"><a href="/test-page?page=1" title="Page 1">1</a></li>', $pager);
$this->assertEquals('<ul class="pagination"><li class="active"><a href="/test-page?page=1" title="Page 1">1</a></li><li><a href="/test-page?page=2" title="Page 2">2</a></li><li><a href="/test-page?page=3" title="Page 3">3</a></li><li><a href="/test-page?page=2" title="Page &gt;">&gt;</a></li><li><a href="/test-page?page=3" title="Page &raquo;">&raquo;</a></li></ul>', $pager);

$alternateCurrent = $this->pagination->setAClass('')->setLiClass('')->setPaginationClass('pagination')->paging(106, '/test-page', 3);
$alternateCurrent = $this->pagination->setAClass('')->setLiClass('')->setAActiveClass('newactive')->setPaginationClass('pagination')->paging(106, '/test-page', 3);
$this->assertStringStartsWith("<ul", $alternateCurrent);
$this->assertStringEndsWith("ul>", $alternateCurrent);
$this->assertStringContainsString('<li class="active"><a href="/test-page?page=3" title="Page 3">3</a></li>', $alternateCurrent);
$this->assertEquals('<ul class="pagination"><li><a href="/test-page" title="Page &laquo;">&laquo;</a></li><li><a href="/test-page?page=2" title="Page &lt;">&lt;</a></li><li><a href="/test-page?page=1" title="Page 1">1</a></li><li><a href="/test-page?page=2" title="Page 2">2</a></li><li class="active"><a href="/test-page?page=3" title="Page 3">3</a></li></ul>', $alternateCurrent);
$this->assertStringContainsString('<li class="active"><a href="/test-page?page=3" title="Page 3" class="newactive">3</a></li>', $alternateCurrent);
$this->assertEquals('<ul class="pagination"><li><a href="/test-page" title="Page &laquo;">&laquo;</a></li><li><a href="/test-page?page=2" title="Page &lt;">&lt;</a></li><li><a href="/test-page?page=1" title="Page 1">1</a></li><li><a href="/test-page?page=2" title="Page 2">2</a></li><li class="active"><a href="/test-page?page=3" title="Page 3" class="newactive">3</a></li></ul>', $alternateCurrent);

$maxLinks = $this->pagination->paging(2506, '/test-page', 0, 50, 11, true);
$this->assertStringContainsString('Page 11', $maxLinks);
Expand Down Expand Up @@ -77,6 +84,9 @@ public function testNoPagerNeeded()
* @covers Pager\Pagination::buildQueryString
* @covers Pager\Pagination::getLiActiveClass
* @covers Pager\Pagination::getPaginationClass
* @covers Pager\Pagination::getAActiveClass
* @covers Pager\Pagination::getAClass
* @covers Pager\Pagination::getLiClass
* @covers Pager\Pagination::postLinks
* @covers Pager\Pagination::preLinks
*/
Expand All @@ -98,6 +108,9 @@ public function testPagerArrows()
* @covers Pager\Pagination::buildQueryString
* @covers Pager\Pagination::getLiActiveClass
* @covers Pager\Pagination::getPaginationClass
* @covers Pager\Pagination::getAActiveClass
* @covers Pager\Pagination::getAClass
* @covers Pager\Pagination::getLiClass
* @covers Pager\Pagination::postLinks
* @covers Pager\Pagination::preLinks
*/
Expand Down

0 comments on commit 67c9417

Please sign in to comment.