Skip to content

Commit

Permalink
Fix and Improve Tests (#186)
Browse files Browse the repository at this point in the history
* Allow PHPUnit 10

* Ran `./vendor/bin/phpunit --migrate-configuration`

* OCD

* Fixing tests

* Drop PHPUnit and keep remaining changes.
  • Loading branch information
spekulatius authored Jun 4, 2023
1 parent dc4dd22 commit 30d40bc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
31 changes: 17 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<coverage/>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
13 changes: 8 additions & 5 deletions tests/CustomSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ public function testFailedSelectionBasedOnId()
$web->title
);

// Check warning through an DOMXPath query.
$this->expectWarning();
$this->expectWarningMessage('DOMXPath::query(): Invalid expression');

// Trigger failing test.
$web->filterFirstText("//[@id='by-id']");
try {
$web->filterFirstText("//[@id='by-id']");
} catch (\Exception $e) {
$this->assertSame(
'DOMXPath::query(): Invalid expression',
$e->getMessage()
);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/MetaKeywordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Spekulatius\PHPScraper\Tests;

class MetaKeywordTest extends \PHPUnit\Framework\TestCase
class MetaKeywordsTest extends \PHPUnit\Framework\TestCase
{
/**
* @test
Expand Down

0 comments on commit 30d40bc

Please sign in to comment.