diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c107478
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/vendor/
+/composer.lock
+/.phpunit.result.cache
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 7e81011..f246acc 100644
--- a/composer.json
+++ b/composer.json
@@ -16,12 +16,15 @@
}
],
"require": {
- "php": ">=5.3.0"
+ "php": ">=7.2.0"
},
"suggest": {
"symfony/css-selector": "Provides facilities is you prefers CSS to Xpath"
},
"autoload": {
"psr-0": { "Welldom": "src/" }
+ },
+ "require-dev": {
+ "symfony/phpunit-bridge": "^5.0"
}
}
diff --git a/tests/Welldom/Tests/DocumentFragmentTest.php b/tests/Welldom/Tests/DocumentFragmentTest.php
index d14844d..c5548b7 100644
--- a/tests/Welldom/Tests/DocumentFragmentTest.php
+++ b/tests/Welldom/Tests/DocumentFragmentTest.php
@@ -11,25 +11,29 @@
namespace Welldom\Tests;
+use PHPUnit\Framework\TestCase;
+
/**
* @covers \Welldom\DocumentFragment
*/
class DocumentFragmentTest extends TestCase
{
+ use TestHelpers;
+
public function testAppendXmlError()
{
$doc = $this->createDocument('');
$fragment = $doc->createDocumentFragment();
$errors = $fragment->getLastErrors();
- $this->assertInternalType('array', $errors);
+ $this->assertIsArray($errors);
$this->assertCount(0, $errors);
$success = $fragment->appendXML(''), '->loadXML() returns false with invalid XML');
- $this->assertInternalType('array', $doc->getLastErrors());
+ $this->assertIsArray($doc->getLastErrors());
$this->assertCount(3, $doc->getLastErrors());
}
diff --git a/tests/Welldom/Tests/ElementTest.php b/tests/Welldom/Tests/ElementTest.php
index a0575ff..cebe357 100644
--- a/tests/Welldom/Tests/ElementTest.php
+++ b/tests/Welldom/Tests/ElementTest.php
@@ -11,11 +11,15 @@
namespace Welldom\Tests;
+use PHPUnit\Framework\TestCase;
+
/**
* @covers \Welldom\Element
*/
class ElementTests extends TestCase
{
+ use TestHelpers;
+
// ->getDocument()
public function testGetDocument()
diff --git a/tests/Welldom/Tests/NodeListTest.php b/tests/Welldom/Tests/NodeListTest.php
index bcdc5a2..03880f5 100644
--- a/tests/Welldom/Tests/NodeListTest.php
+++ b/tests/Welldom/Tests/NodeListTest.php
@@ -11,8 +11,11 @@
namespace Welldom\Tests;
+use PHPUnit\Framework\TestCase;
+
class NodeListTest extends TestCase
{
+ use TestHelpers;
// ->getIterator()
diff --git a/tests/Welldom/Tests/TestCase.php b/tests/Welldom/Tests/TestHelpers.php
similarity index 91%
rename from tests/Welldom/Tests/TestCase.php
rename to tests/Welldom/Tests/TestHelpers.php
index 033bc4e..9948534 100644
--- a/tests/Welldom/Tests/TestCase.php
+++ b/tests/Welldom/Tests/TestHelpers.php
@@ -13,7 +13,7 @@
use Welldom\Document;
-class TestCase extends \PHPUnit_Framework_TestCase
+trait TestHelpers
{
/**
* @param string $source XML source
diff --git a/tests/Welldom/Tests/XmlSerializerTest.php b/tests/Welldom/Tests/XmlSerializerTest.php
index 8dcffb3..e9031ed 100644
--- a/tests/Welldom/Tests/XmlSerializerTest.php
+++ b/tests/Welldom/Tests/XmlSerializerTest.php
@@ -11,6 +11,7 @@
namespace Welldom\Tests;
+use PHPUnit\Framework\TestCase;
use Welldom\XmlSerializer;
/**
@@ -18,6 +19,8 @@
*/
class XmlSerializerTest extends TestCase
{
+ use TestHelpers;
+
/**
* @dataProvider dataForTestXmlToArrayToXml
*/
diff --git a/tests/Welldom/Tests/XpathTest.php b/tests/Welldom/Tests/XpathTest.php
index d67250b..b0e191a 100644
--- a/tests/Welldom/Tests/XpathTest.php
+++ b/tests/Welldom/Tests/XpathTest.php
@@ -11,6 +11,8 @@
namespace Welldom\Tests;
+use PHPUnit\Framework\TestCase;
+use Welldom\Exception\InvalidXpathException;
use Welldom\Xpath;
/**
@@ -18,6 +20,7 @@
*/
class XpathTest extends TestCase
{
+ use TestHelpers;
/**
* @covers Welldom\Xpath::queryOne
@@ -32,10 +35,10 @@ public function testQueryOne()
/**
* @covers Welldom\Xpath::queryOne
- * @expectedException \Welldom\Exception\InvalidXpathException
*/
public function testQueryOneException()
{
+ $this->expectException(InvalidXpathException::class);
$this->getXpath('')->queryOne('foo[');
}
@@ -52,10 +55,10 @@ public function testQuery()
/**
* @covers Welldom\Xpath::query
- * @expectedException \Welldom\Exception\InvalidXpathException
*/
public function testQueryException()
{
+ $this->expectException(InvalidXpathException::class);
$this->getXpath('')->query('foo[');
}
@@ -71,10 +74,10 @@ public function testEvaluate()
/**
* @covers Welldom\Xpath::evaluate
- * @expectedException \Welldom\Exception\InvalidXpathException
*/
public function testEvaluateException()
{
+ $this->expectException(InvalidXpathException::class);
$this->getXpath('')->evaluate('foo[');
}
diff --git a/tests/Welldom/Tests/XsltProcessorCollectionTest.php b/tests/Welldom/Tests/XsltProcessorCollectionTest.php
index 249be06..18eb29c 100644
--- a/tests/Welldom/Tests/XsltProcessorCollectionTest.php
+++ b/tests/Welldom/Tests/XsltProcessorCollectionTest.php
@@ -11,6 +11,7 @@
namespace Welldom\Tests;
+use PHPUnit\Framework\TestCase;
use Welldom\XsltProcessorCollection;
/**
@@ -18,6 +19,8 @@
*/
class XsltProcessorCollectionTest extends TestCase
{
+ use TestHelpers;
+
public function testGetXsltProcessor()
{
$filename = FILES_DIR . '/frameworks.xsl';
@@ -27,19 +30,15 @@ public function testGetXsltProcessor()
XsltProcessorCollection::free();
}
- /**
- * @expectedException \DOMException
- */
public function testGetXsltProcessorLoadException()
{
+ $this->expectException(\DOMException::class);
XsltProcessorCollection::getXsltProcessor(FILES_DIR . '/frameworks-invalid.xsl');
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testGetXsltProcessorFileException()
{
+ $this->expectException(\InvalidArgumentException::class);
XsltProcessorCollection::getXsltProcessor(FILES_DIR . '/does-not-exists.xsl');
}
}
diff --git a/tests/Welldom/Tests/XsltProcessorTest.php b/tests/Welldom/Tests/XsltProcessorTest.php
index 180ae00..a865d42 100644
--- a/tests/Welldom/Tests/XsltProcessorTest.php
+++ b/tests/Welldom/Tests/XsltProcessorTest.php
@@ -11,6 +11,7 @@
namespace Welldom\Tests;
+use PHPUnit\Framework\TestCase;
use Welldom\XsltProcessor;
use Welldom\Document;
@@ -19,6 +20,7 @@
*/
class XsltProcessorTest extends TestCase
{
+ use TestHelpers;
// ->__construct()
@@ -29,7 +31,7 @@ public function testConstructor($filename, $errorsCount)
{
$xslt = new XsltProcessor(FILES_DIR . $filename);
- $this->assertInternalType('array', $xslt->getLastErrors());
+ $this->assertIsArray($xslt->getLastErrors());
$this->assertCount($errorsCount, $xslt->getLastErrors());
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 02073ba..9ad57b1 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -10,5 +10,5 @@
*/
require_once __DIR__ . '/../src/autoload.php';
-require_once __DIR__ . '/Welldom/Tests/TestCase.php';
+require_once __DIR__ . '/Welldom/Tests/TestHelpers.php';
define('FILES_DIR', realpath(__DIR__ . '/_files'));