Skip to content

Commit

Permalink
Merge pull request #76 from phptal/feature/drop-eol-php-versions
Browse files Browse the repository at this point in the history
Upgraded to PHPUnit 9.x, dropped PHP <7.3, dropped PhpDocumentor dependency
  • Loading branch information
Ocramius authored Mar 27, 2021
2 parents 9cd6bce + 8829776 commit 0ba925f
Show file tree
Hide file tree
Showing 38 changed files with 343 additions and 419 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ all::test docs doc
test::
tools/phpunit

docs::
tools/phpdoc -d classes -t docs -p

doc::
$(MAKE) $(MFLAGS) -C doc

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
Requirements
============

To use PHPTAL in your projects, you will only require PHP 5.1.2 or later.

If you want to use the builtin internationalisation system (I18N), the php-gettext extension must be installed or compiled into PHP (`--with-gettext`).

Composer install (recommended)
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
}
],
"require": {
"php": "^7.1 || ^8.0"
"php": "^7.3 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5",
"phpdocumentor/phpdocumentor": "^2.9"
"phpunit/phpunit": "^9.5.4"
},
"autoload": {
"psr-0": {
Expand Down
20 changes: 4 additions & 16 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
<!--
This is PHPUnit configuration file. Install PHPUnit:
http://www.phpunit.de/manual/3.5/en/installation.html
and run "phpunit" command in this directory. It will run all tests,
ensuring that your copy of PHPTAL works correctly.
--><phpunit
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./tests/config.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">
>
<php>
<ini name="display_errors" value="1"/>
<ini name="zend.exception_ignore_args" value="0"/>
Expand Down
7 changes: 3 additions & 4 deletions tests/BlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ function testSomeNamespaceBlock()
$this->assertEquals('<foo:block xmlns:foo="http://phptal.example.com">foo</foo:block>', $res);
}

/**
* @expectedException PHPTAL_ParserException
*/
function testInvalidNamespaceBlock()
{
$t = $this->newPHPTAL();

$t->setSource('<foo:block>foo</foo:block>');
$res = $t->execute();

$this->expectException(PHPTAL_ParserException::class);
$t->execute();
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/CodeCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ private function resetPHPTAL()

private function clearCache()
{
$this->assertContains(DIRECTORY_SEPARATOR.'temp_output'.DIRECTORY_SEPARATOR, $this->codeDestination);
$this->assertStringContainsString(DIRECTORY_SEPARATOR.'temp_output'.DIRECTORY_SEPARATOR, $this->codeDestination);
foreach (glob($this->codeDestination.'tpl_*') as $tpl) {
$this->assertTrue(unlink($tpl), "Delete $tpl");
}
}

function setUp()
function setUp(): void
{
parent::setUp();
$this->resetPHPTAL();
$this->clearCache();
}

function tearDown()
function tearDown(): void
{
$this->clearCache();
parent::tearDown();
Expand Down Expand Up @@ -151,7 +151,7 @@ function testGarbageRemoval()

// can't check for reparse, because PHPTAL uses function_exists() as a shortcut!
foreach ($files as $file) {
$this->assertFileNotExists($file);
$this->assertFileDoesNotExist($file);
}
}

Expand Down
16 changes: 6 additions & 10 deletions tests/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,24 @@ function testShortComments()
$this->assertEquals($source, $res);
}

/**
* @expectedException PHPTAL_ParserException
*/
function testNestedComments()
{
$source = '<html><!--<!--<!--></html>';
$tpl = $this->newPHPTAL();
$tpl->setSource($source);
$res = $tpl->execute();
$this->fail("Ill-formed comment accepted");

$this->expectException(PHPTAL_ParserException::class);
$tpl->execute();
}

/**
* @expectedException PHPTAL_ParserException
*/
function testDashedComment()
{
$source = '<html><!--- XML hates you ---></html>';
$tpl = $this->newPHPTAL();
$tpl->setSource($source);
$res = $tpl->execute();
$this->fail("Ill-formed comment accepted");

$this->expectException(PHPTAL_ParserException::class);
$tpl->execute();
}


Expand Down
15 changes: 6 additions & 9 deletions tests/ContentInterpolationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,34 +308,31 @@ public function testPHPBlock54()
ini_restore('short_open_tag');
}

/**
* @expectedException PHPTAL_VariableNotFoundException
*/
function testErrorsThrow()
{
$tpl = $this->newPHPTAL();
$tpl->setSource('<p>${error}</p>');

$this->expectException(PHPTAL_VariableNotFoundException::class);
$tpl->execute();
}

/**
* @expectedException PHPTAL_VariableNotFoundException
*/
function testErrorsThrow2()
{
$tpl = $this->newPHPTAL();
$tpl->setSource('<p>${error | error}</p>');

$this->expectException(PHPTAL_VariableNotFoundException::class);
$tpl->execute();
}

/**
* @expectedException PHPTAL_VariableNotFoundException
*/
function testErrorsThrow3()
{
$tpl = $this->newPHPTAL();
$tpl->foo = array();
$tpl->setSource('<p>${foo/error | foo/error}</p>');

$this->expectException(PHPTAL_VariableNotFoundException::class);
$tpl->execute();
}

Expand Down
8 changes: 4 additions & 4 deletions tests/DoctypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ function testClearedOnReexecution()
$tpl = $this->newPHPTAL();
$tpl->setSource('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><whatever/>');

$this->assertContains("DOCTYPE html PUBLIC", $tpl->execute());
$this->assertContains("DOCTYPE html PUBLIC", $tpl->execute());
$this->assertStringContainsString("DOCTYPE html PUBLIC", $tpl->execute());
$this->assertStringContainsString("DOCTYPE html PUBLIC", $tpl->execute());

$tpl->setSource('<whatever/>');

$this->assertNotContains("DOCTYPE html PUBLIC", $tpl->execute());
$this->assertNotContains("DOCTYPE html PUBLIC", $tpl->execute());
$this->assertStringNotContainsString("DOCTYPE html PUBLIC", $tpl->execute());
$this->assertStringNotContainsString("DOCTYPE html PUBLIC", $tpl->execute());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/DomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function testAppendChild()
$el1 = $this->newElement();
$el2 = $this->newElement();

$this->assertInternalType('array', $el1->childNodes);
$this->assertIsArray($el1->childNodes);
$this->assertNull($el2->parentNode);

$el1->appendChild($el2);
Expand Down
2 changes: 1 addition & 1 deletion tests/EchoExecuteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function testEchoExecuteDeclsMacro()
catch(PHPTAL_ConfigurationException $e)
{
// this is fine. Combination of macros and echoExecute is not supported yet (if it were, the test above is valid)
$this->assertContains("echoExecute", $e->getMessage());
$this->assertStringContainsString("echoExecute", $e->getMessage());
}
}
}
66 changes: 33 additions & 33 deletions tests/EscapeHTMLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function testDoesEscapeHTMLContent(){
function testEntityDecodingPath1()
{
$res = $this->executeString('<div title="&quot;" class=\'&quot;\' tal:content="\'&quot; quote character\'" />');
$this->assertNotContains('&amp;', $res);
$this->assertStringNotContainsString('&amp;', $res);
}

function testEntityDecodingBeforePHP()
Expand All @@ -61,110 +61,110 @@ function testNoEntityEncodingAfterStructurePHP()
function testDecodingBeforeStructure()
{
$res = $this->executeString('<div tal:content="structure php:\'&amp; quote character\'" />');
$this->assertNotContains('&amp;', $res);
$this->assertStringNotContainsString('&amp;', $res);
}

function testEntityDecodingPHP1()
{
$res = $this->executeString('<div tal:content="php:\'&quot; quote character\'" />');
$this->assertNotContains('&amp;', $res);
$this->assertStringNotContainsString('&amp;', $res);
}

function testEntityDecodingPath2()
{
$res = $this->executeString('<div tal:attributes="title \'&quot; quote character\'" />');
$this->assertNotContains('&amp;', $res);
$this->assertStringNotContainsString('&amp;', $res);
}

function testEntityDecodingPHP2()
{
$res = $this->executeString('<div tal:attributes="title php:\'&quot; quote character\'" />');
$this->assertNotContains('&amp;', $res);
$this->assertStringNotContainsString('&amp;', $res);
}

function testEntityDecodingPath3()
{
$res = $this->executeString('<p>${\'&quot; quote character\'}</p>');
$this->assertNotContains('&amp;', $res);
$this->assertStringNotContainsString('&amp;', $res);
}

function testEntityDecodingPHP3()
{
$res = $this->executeString('<p>${php:\'&quot; quote character\'}</p>');
$this->assertNotContains('&amp;', $res);
$this->assertStringNotContainsString('&amp;', $res);
}


function testEntityEncodingPath1()
{
$res = $this->executeString('<div tal:content="\'&amp; ampersand character\'" />');
$this->assertContains('&amp;', $res);
$this->assertNotContains('&amp;amp;', $res);
$this->assertNotContains('&amp;&amp;', $res);
$this->assertStringContainsString('&amp;', $res);
$this->assertStringNotContainsString('&amp;amp;', $res);
$this->assertStringNotContainsString('&amp;&amp;', $res);
}

function testEntityEncodingPHP1()
{
$res = $this->executeString('<div tal:content="php:\'&amp; ampersand character\'" />');
$this->assertContains('&amp;', $res);
$this->assertNotContains('&amp;amp;', $res);
$this->assertNotContains('&amp;&amp;', $res);
$this->assertStringContainsString('&amp;', $res);
$this->assertStringNotContainsString('&amp;amp;', $res);
$this->assertStringNotContainsString('&amp;&amp;', $res);
}

function testEntityEncodingPath2()
{
$res = $this->executeString('<div tal:attributes="title \'&amp; ampersand character\'" />');
$this->assertContains('&amp;', $res);
$this->assertNotContains('&amp;amp;', $res);
$this->assertNotContains('&amp;&amp;', $res);
$this->assertStringContainsString('&amp;', $res);
$this->assertStringNotContainsString('&amp;amp;', $res);
$this->assertStringNotContainsString('&amp;&amp;', $res);
}

function testEntityEncodingVariables()
{
$res = $this->executeString('<div tal:attributes="title variable; class variable">${variable}${php:variable}</div>',
array('variable'=>'& = ampersand, " = quote, \' = apostrophe'));
$this->assertContains('&amp;',$res);
$this->assertNotContains('&amp;amp;',$res);
$this->assertNotContains('&amp;&amp;',$res);
$this->assertStringContainsString('&amp;',$res);
$this->assertStringNotContainsString('&amp;amp;',$res);
$this->assertStringNotContainsString('&amp;&amp;',$res);
}

function testEntityEncodingAttributesDefault1()
{
$res = $this->executeString('<div tal:attributes="title idontexist | default" title=\'&amp; ampersand character\' />');
$this->assertContains('&amp;', $res);
$this->assertNotContains('&amp;amp;', $res);
$this->assertNotContains('&amp;&amp;', $res);
$this->assertStringContainsString('&amp;', $res);
$this->assertStringNotContainsString('&amp;amp;', $res);
$this->assertStringNotContainsString('&amp;&amp;', $res);
}

function testEntityEncodingAttributesDefault2()
{
$res = $this->executeString('<div tal:attributes="title idontexist | default" title=\'&quot;&apos;\' />');
$this->assertNotContains('&amp;', $res);
$this->assertContains('&quot;', $res); // or apos...
$this->assertStringNotContainsString('&amp;', $res);
$this->assertStringContainsString('&quot;', $res); // or apos...
}

function testEntityEncodingPHP2()
{
$res = $this->executeString('<div tal:attributes="title php:\'&amp; ampersand character\'" />');
$this->assertContains('&amp;', $res);
$this->assertNotContains('&amp;amp;', $res);
$this->assertNotContains('&amp;&amp;', $res);
$this->assertStringContainsString('&amp;', $res);
$this->assertStringNotContainsString('&amp;amp;', $res);
$this->assertStringNotContainsString('&amp;&amp;', $res);
}

function testEntityEncodingPath3()
{
$res = $this->executeString('<p>${\'&amp; ampersand character\'}</p>');
$this->assertContains('&amp;', $res);
$this->assertNotContains('&amp;amp;', $res);
$this->assertNotContains('&amp;&amp;', $res);
$this->assertStringContainsString('&amp;', $res);
$this->assertStringNotContainsString('&amp;amp;', $res);
$this->assertStringNotContainsString('&amp;&amp;', $res);
}

function testEntityEncodingPHP3()
{
$res = $this->executeString('<p>&{php:\'&amp; ampersand character\'}</p>');
$this->assertContains('&amp;', $res);
$this->assertNotContains('&amp;amp;', $res);
$this->assertNotContains('&amp;&amp;', $res);
$this->assertStringContainsString('&amp;', $res);
$this->assertStringNotContainsString('&amp;amp;', $res);
$this->assertStringNotContainsString('&amp;&amp;', $res);
}

function testSimpleXML()
Expand Down
Loading

0 comments on commit 0ba925f

Please sign in to comment.