Skip to content

Commit

Permalink
Merge pull request #73 from hason-contributions/php8
Browse files Browse the repository at this point in the history
Enable PHP 8.0 and use Github Actions
  • Loading branch information
goetas authored Jan 23, 2021
2 parents 6ad9e40 + a403313 commit 188403e
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 116 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Tests

on:
push: ~
pull_request: ~

jobs:
phpunit:
name: PHPUnit on ${{ matrix.php }} and Twig ${{ matrix.twig }} ${{ matrix.dependencies }}
runs-on: ubuntu-latest
strategy:
matrix:
dependencies: ['', 'lowest']
php: [ '7.1', '7.2', '7.3', '7.4', '8.0' ]
twig: [ ^1.0, ^2.0, ^3.0 ]
exclude:
- php: '7.1'
twig: ^3.0
steps:
- name: Update code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom
coverage: pcov
tools: composer:v2

- name: Install dependencies
run: composer update --no-progress --with "twig/twig:${{ matrix.twig }}"

- name: Install lowest dependencies
run: composer update --no-progress --prefer-lowest --root-reqs --with "twig/twig:${{ matrix.twig }}"
if: matrix.dependencies

- name: Run tests
run: vendor/bin/phpunit --no-coverage
if: matrix.php != '8.0'

- name: Run tests with code coverage
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
if: matrix.php == '8.0'

- name: Upload code coverage tu Scrutinizer
run: php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
if: matrix.php == '8.0'
68 changes: 0 additions & 68 deletions .travis.yml

This file was deleted.

12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"homepage" : "https://github.com/goetas/twital",
"license" : "MIT",
"require" : {
"php" : "^5.5|^7.0",
"php" : "^7.1|^8.0",
"ext-dom": "*",
"masterminds/html5" : "^2.1.2",
"twig/twig" : "^1.38|^2.4|^3.0",
"symfony/event-dispatcher" : "^3.0|^4.0|^5.0"
"twig/twig" : "^1.43|^2.13|^3.0",
"symfony/event-dispatcher" : "^3.4|^4.4|^5.1"
},
"require-dev" : {
"phpunit/phpunit" : "4.8.34|^5.6.3|^6.0|^7.0",
"phpunit/phpunit" : "^7.5|^8.0|^9.0",
"friendsofphp/php-cs-fixer": "^2.2",
"sebastian/comparator": ">=1.2.3",
"symfony/var-dumper": "^3.0|^4.0|^5.0"
"scrutinizer/ocular": "^1.3",
"symfony/var-dumper": "^3.4|^4.4|^5.1"
},
"autoload" : {
"psr-4" : {
Expand Down
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
<whitelist>
<directory>src</directory>
</whitelist>
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
</phpunit>

3 changes: 0 additions & 3 deletions src/SourceAdapter/XMLAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,15 @@ protected function collectMetadata(\DOMDocument $dom, $source)
protected function createDom($source)
{
$internalErrors = libxml_use_internal_errors(true);
$disableEntities = libxml_disable_entity_loader(true);
libxml_clear_errors();

$dom = new \DOMDocument('1.0', 'UTF-8');
if ('' !== trim($source) && !$dom->loadXML($source, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
libxml_disable_entity_loader($disableEntities);

throw new \InvalidArgumentException(implode("\n", $this->getXmlErrors($internalErrors)));
}

libxml_use_internal_errors($internalErrors);
libxml_disable_entity_loader($disableEntities);

return $dom;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Tests/ContextAwareEscapingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Goetas\Twital\SourceAdapter\XHTMLAdapter;
use Goetas\Twital\SourceAdapter\XMLAdapter;
use Goetas\Twital\Twital;
use PHPUnit\Framework\TestCase;

class ContextAwareEscapingTest extends TestCase
{
Expand All @@ -13,7 +14,7 @@ class ContextAwareEscapingTest extends TestCase
/**
* Prepares the environment before running a test.
*/
protected function setUp()
protected function setUp(): void
{
$this->twital = new Twital();
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Tests/CoreAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

use Goetas\Twital\SourceAdapter\XMLAdapter;
use Goetas\Twital\Twital;
use PHPUnit\Framework\TestCase;

class CoreAttributeTest extends TestCase
{
/**
* Prepares the environment before running a test.
*/
protected function setUp()
protected function setUp():void
{
parent::setUp();
$this->twital = new Twital();
Expand Down
3 changes: 2 additions & 1 deletion tests/Tests/CoreNodesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Goetas\Twital\Tests;

use Goetas\Twital\Twital;
use PHPUnit\Framework\TestCase;

abstract class CoreNodesTest extends TestCase
{
Expand All @@ -10,7 +11,7 @@ abstract class CoreNodesTest extends TestCase
/**
* Prepares the environment before running a test.
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->twital = new Twital();
Expand Down
5 changes: 3 additions & 2 deletions tests/Tests/DynamicAttrAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Goetas\Twital\SourceAdapter\XMLAdapter;
use Goetas\Twital\TwitalLoader;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Loader\ArrayLoader;

Expand All @@ -21,7 +22,7 @@ class DynamicAttrAttributeTest extends TestCase
/**
* Prepares the environment before running a test.
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -120,10 +121,10 @@ public function getInvalidData()

/**
* @dataProvider getInvalidData
* @expectedException \Exception
*/
public function testInvalidVisitAttribute($source)
{
$this->expectException(\Exception::class);
$this->loader->setTemplate('template', $source);
$this->twig->render('template');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Tests/Event/SourceEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace Goetas\Twital\Tests\Event;

use Goetas\Twital\EventDispatcher\SourceEvent;
use Goetas\Twital\Tests\TestCase;
use Goetas\Twital\Twital;
use PHPUnit\Framework\TestCase;

class SourceEventTest extends TestCase
{
Expand All @@ -12,7 +12,7 @@ class SourceEventTest extends TestCase
/**
* Prepares the environment before running a test.
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->twital = new Twital();
Expand Down
4 changes: 2 additions & 2 deletions tests/Tests/Event/TemplateEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

use Goetas\Twital\EventDispatcher\TemplateEvent;
use Goetas\Twital\Template;
use Goetas\Twital\Tests\TestCase;
use Goetas\Twital\Twital;
use PHPUnit\Framework\TestCase;

class TemplateEventTest extends TestCase
{
Expand All @@ -14,7 +14,7 @@ class TemplateEventTest extends TestCase
/**
* Prepares the environment before running a test.
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->twital = new Twital();
Expand Down
5 changes: 3 additions & 2 deletions tests/Tests/ExpressionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Goetas\Twital\Tests;

use Goetas\Twital\Helper\ParserHelper;
use PHPUnit\Framework\TestCase;

class ExpressionParserTest extends TestCase
{
Expand All @@ -25,11 +26,11 @@ public function testExpressionsWithLimit($expression, $splitter, $limit, $expect

/**
* @dataProvider getWrongData
* @expectedException Exception
*/
public function testWrongExpressions($expression)
{
$splitted = ParserHelper::staticSplitExpression($expression, "x");
$this->expectException(\Exception::class);
ParserHelper::staticSplitExpression($expression, "x");
}

public function getWrongData()
Expand Down
3 changes: 2 additions & 1 deletion tests/Tests/FullCompatibilityTwigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Goetas\Twital\Extension\FullCompatibilityTwigExtension;
use Goetas\Twital\SourceAdapter\HTML5Adapter;
use Goetas\Twital\Twital;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class FullCompatibilityTwigTest extends TestCase
Expand All @@ -18,7 +19,7 @@ class FullCompatibilityTwigTest extends TestCase
/**
* Prepares the environment before running a test.
*/
protected function setUp()
protected function setUp(): void
{
$this->templateSubscriber = new DebugTemplateSubscriber();

Expand Down
3 changes: 2 additions & 1 deletion tests/Tests/Html5DynamicAttrAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Goetas\Twital\SourceAdapter\HTML5Adapter;
use Goetas\Twital\TwitalLoader;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Loader\ArrayLoader;

Expand All @@ -21,7 +22,7 @@ class Html5DynamicAttrAttributeTest extends TestCase
/**
* Prepares the environment before running a test.
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
23 changes: 0 additions & 23 deletions tests/Tests/TestCase.php

This file was deleted.

1 change: 1 addition & 0 deletions tests/Tests/TwitalLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Goetas\Twital\SourceAdapter\XMLAdapter;
use Goetas\Twital\Twital;
use Goetas\Twital\TwitalLoader;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Loader\ArrayLoader;
Expand Down

0 comments on commit 188403e

Please sign in to comment.