Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to PHPUnit 9 #404

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"php": ">=5.2.4"
},
"require-dev": {
"phpunit/phpunit": "~3.7|~4.0|~5.0",
"friendsofphp/php-cs-fixer": "~1.11"
"phpunit/phpunit": "^9",
"friendsofphp/php-cs-fixer": "^3"
},
"autoload": {
"psr-0": { "Mustache": "src/" }
Expand Down
32 changes: 16 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" colors="true" bootstrap="./test/bootstrap.php">
<testsuite name="Mustache">
<directory suffix="Test.php">./test</directory>
<exclude>./test/Mustache/Test/FiveThree</exclude>
</testsuite>

<testsuite name="Mustache FiveThree">
<directory suffix="Test.php" phpVersion="5.3.0" phpVersionOperator=">=">./test/Mustache/Test/FiveThree</directory>
</testsuite>

<filter>
<whitelist>
<directory suffix=".php">./src/Mustache</directory>
</whitelist>
</filter>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" bootstrap="./test/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/Mustache</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Mustache">
<directory suffix="Test.php">./test</directory>
<exclude>./test/Mustache/Test/FiveThree</exclude>
</testsuite>
<testsuite name="Mustache FiveThree">
<directory suffix="Test.php" phpVersion="5.3.0" phpVersionOperator="&gt;=">./test/Mustache/Test/FiveThree</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion test/Mustache/Test/AutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @group unit
*/
class Mustache_Test_AutoloaderTest extends PHPUnit_Framework_TestCase
class Mustache_Test_AutoloaderTest extends \PHPUnit\Framework\TestCase
{
public function testRegister()
{
Expand Down
6 changes: 2 additions & 4 deletions test/Mustache/Test/Cache/AbstractCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

class Mustache_Test_Cache_AbstractCacheTest extends PHPUnit_Framework_TestCase
class Mustache_Test_Cache_AbstractCacheTest extends \PHPUnit\Framework\TestCase
{
public function testGetSetLogger()
{
Expand All @@ -19,13 +19,11 @@ public function testGetSetLogger()
$this->assertSame($logger, $cache->getLogger());
}

/**
* @expectedException Mustache_Exception_InvalidArgumentException
*/
public function testSetLoggerThrowsExceptions()
{
$cache = new CacheStub();
$logger = new StdClass();
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$cache->setLogger($logger);
}
}
Expand Down
8 changes: 3 additions & 5 deletions test/Mustache/Test/CompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @group unit
*/
class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
class Mustache_Test_CompilerTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider getCompileValues
Expand All @@ -23,7 +23,7 @@ public function testCompile($source, array $tree, $name, $customEscaper, $entity

$compiled = $compiler->compile($source, $tree, $name, $customEscaper, $charset, false, $entityFlags);
foreach ($expected as $contains) {
$this->assertContains($contains, $compiled);
$this->assertStringContainsString($contains, $compiled);
}
}

Expand Down Expand Up @@ -132,12 +132,10 @@ public function getCompileValues()
);
}

/**
* @expectedException Mustache_Exception_SyntaxException
*/
public function testCompilerThrowsSyntaxException()
{
$compiler = new Mustache_Compiler();
$this->expectException(Mustache_Exception_SyntaxException::class);
$compiler->compile('', array(array(Mustache_Tokenizer::TYPE => 'invalid')), 'SomeClass');
}

Expand Down
6 changes: 2 additions & 4 deletions test/Mustache/Test/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @group unit
*/
class Mustache_Test_ContextTest extends PHPUnit_Framework_TestCase
class Mustache_Test_ContextTest extends \PHPUnit\Framework\TestCase
{
public function testConstructor()
{
Expand Down Expand Up @@ -171,13 +171,11 @@ public function testAnchoredDotNotation()
$this->assertEquals('', $context->findAnchoredDot('.child.name'));
}

/**
* @expectedException Mustache_Exception_InvalidArgumentException
*/
public function testAnchoredDotNotationThrowsExceptions()
{
$context = new Mustache_Context();
$context->push(array('a' => 1));
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$context->findAnchoredDot('a');
}
}
Expand Down
32 changes: 11 additions & 21 deletions test/Mustache/Test/EngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testConstructor()
$this->assertSame($loader, $mustache->getLoader());
$this->assertSame($partialsLoader, $mustache->getPartialsLoader());
$this->assertEquals('{{ foo }}', $partialsLoader->load('foo'));
$this->assertContains('__whot__', $mustache->getTemplateClassName('{{ foo }}'));
$this->assertStringContainsString('__whot__', $mustache->getTemplateClassName('{{ foo }}'));
$this->assertEquals('strtoupper', $mustache->getEscape());
$this->assertEquals(ENT_QUOTES, $mustache->getEntityFlags());
$this->assertEquals('ISO-8859-1', $mustache->getCharset());
Expand Down Expand Up @@ -158,22 +158,20 @@ public function testWithoutLambdaCache()
$this->assertNotSame($mustache->getCache(), $mustache->getProtectedLambdaCache());
}

/**
* @expectedException Mustache_Exception_InvalidArgumentException
*/
public function testEmptyTemplatePrefixThrowsException()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
new Mustache_Engine(array(
'template_class_prefix' => '',
));
}

/**
* @expectedException Mustache_Exception_InvalidArgumentException
* @dataProvider getBadEscapers
*/
public function testNonCallableEscapeThrowsException($escape)
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
new Mustache_Engine(array('escape' => $escape));
}

Expand All @@ -185,15 +183,13 @@ public function getBadEscapers()
);
}

/**
* @expectedException Mustache_Exception_RuntimeException
*/
public function testImmutablePartialsLoadersThrowException()
{
$mustache = new Mustache_Engine(array(
'partials_loader' => new Mustache_Loader_StringLoader(),
));

$this->expectException(Mustache_Exception_RuntimeException::class);
$mustache->setPartials(array('foo' => '{{ foo }}'));
}

Expand Down Expand Up @@ -250,21 +246,17 @@ public static function wrapWithUnderscores($text)
return '__' . $text . '__';
}

/**
* @expectedException Mustache_Exception_InvalidArgumentException
*/
public function testSetHelpersThrowsExceptions()
{
$mustache = new Mustache_Engine();
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$mustache->setHelpers('monkeymonkeymonkey');
}

/**
* @expectedException Mustache_Exception_InvalidArgumentException
*/
public function testSetLoggerThrowsExceptions()
{
$mustache = new Mustache_Engine();
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
$mustache->setLogger(new StdClass());
}

Expand Down Expand Up @@ -305,14 +297,14 @@ public function testPartialLoadFailLogging()
$result = $mustache->render('{{> foo }}{{> bar }}{{> baz }}', array());
$this->assertEquals('FOOBAR', $result);

$this->assertContains('WARNING: Partial not found: "baz"', file_get_contents($name));
$this->assertStringContainsString('WARNING: Partial not found: "baz"', file_get_contents($name));
}

public function testCacheWarningLogging()
{
list($name, $mustache) = $this->getLoggedMustache(Mustache_Logger::WARNING);
$mustache->render('{{ foo }}', array('foo' => 'FOO'));
$this->assertContains('WARNING: Template cache disabled, evaluating', file_get_contents($name));
$this->assertStringContainsString('WARNING: Template cache disabled, evaluating', file_get_contents($name));
}

public function testLoggingIsNotTooAnnoying()
Expand All @@ -327,15 +319,13 @@ public function testVerboseLoggingIsVerbose()
list($name, $mustache) = $this->getLoggedMustache(Mustache_Logger::DEBUG);
$mustache->render('{{ foo }}{{> bar }}', array('foo' => 'FOO'));
$log = file_get_contents($name);
$this->assertContains('DEBUG: Instantiating template: ', $log);
$this->assertContains('WARNING: Partial not found: "bar"', $log);
$this->assertStringContainsString('DEBUG: Instantiating template: ', $log);
$this->assertStringContainsString('WARNING: Partial not found: "bar"', $log);
}

/**
* @expectedException Mustache_Exception_InvalidArgumentException
*/
public function testUnknownPragmaThrowsException()
{
$this->expectException(Mustache_Exception_InvalidArgumentException::class);
new Mustache_Engine(array(
'pragmas' => array('UNKNOWN'),
));
Expand Down
2 changes: 1 addition & 1 deletion test/Mustache/Test/Exception/SyntaxExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

class Mustache_Test_Exception_SyntaxExceptionTest extends PHPUnit_Framework_TestCase
class Mustache_Test_Exception_SyntaxExceptionTest extends \PHPUnit\Framework\TestCase
{
public function testInstance()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

class Mustache_Test_Exception_UnknownFilterExceptionTest extends PHPUnit_Framework_TestCase
class Mustache_Test_Exception_UnknownFilterExceptionTest extends \PHPUnit\Framework\TestCase
{
public function testInstance()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

class Mustache_Test_Exception_UnknownHelperExceptionTest extends PHPUnit_Framework_TestCase
class Mustache_Test_Exception_UnknownHelperExceptionTest extends \PHPUnit\Framework\TestCase
{
public function testInstance()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

class Mustache_Test_Exception_UnknownTemplateExceptionTest extends PHPUnit_Framework_TestCase
class Mustache_Test_Exception_UnknownTemplateExceptionTest extends \PHPUnit\Framework\TestCase
{
public function testInstance()
{
Expand Down
4 changes: 2 additions & 2 deletions test/Mustache/Test/FiveThree/Functional/ClosureQuirksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* @group lambdas
* @group functional
*/
class Mustache_Test_FiveThree_Functional_ClosureQuirksTest extends PHPUnit_Framework_TestCase
class Mustache_Test_FiveThree_Functional_ClosureQuirksTest extends \PHPUnit\Framework\TestCase
{
private $mustache;

public function setUp()
protected function setUp(): void
{
$this->mustache = new Mustache_Engine();
}
Expand Down
2 changes: 1 addition & 1 deletion test/Mustache/Test/FiveThree/Functional/EngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @group pragmas
* @group functional
*/
class Mustache_Test_FiveThree_Functional_EngineTest extends PHPUnit_Framework_TestCase
class Mustache_Test_FiveThree_Functional_EngineTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider pragmaData
Expand Down
6 changes: 3 additions & 3 deletions test/Mustache/Test/FiveThree/Functional/FiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* @group filters
* @group functional
*/
class Mustache_Test_FiveThree_Functional_FiltersTest extends PHPUnit_Framework_TestCase
class Mustache_Test_FiveThree_Functional_FiltersTest extends \PHPUnit\Framework\TestCase
{
private $mustache;

public function setUp()
protected function setUp(): void
{
$this->mustache = new Mustache_Engine();
}
Expand Down Expand Up @@ -128,11 +128,11 @@ public function interpolateFirstData()
}

/**
* @expectedException Mustache_Exception_UnknownFilterException
* @dataProvider brokenPipeData
*/
public function testThrowsExceptionForBrokenPipes($tpl, $data)
{
$this->expectException(Mustache_Exception_UnknownFilterException::class);
$this->mustache->render($tpl, $data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* @group lambdas
* @group functional
*/
class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends PHPUnit_Framework_TestCase
class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends \PHPUnit\Framework\TestCase
{
private $mustache;

public function setUp()
protected function setUp(): void
{
$this->mustache = new Mustache_Engine();
}
Expand Down
4 changes: 2 additions & 2 deletions test/Mustache/Test/FiveThree/Functional/LambdaHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* @group lambdas
* @group functional
*/
class Mustache_Test_FiveThree_Functional_LambdaHelperTest extends PHPUnit_Framework_TestCase
class Mustache_Test_FiveThree_Functional_LambdaHelperTest extends \PHPUnit\Framework\TestCase
{
private $mustache;

public function setUp()
protected function setUp(): void
{
$this->mustache = new Mustache_Engine();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function testSpecInitialized()
if (!file_exists(dirname(__FILE__) . '/../../../../../vendor/spec/specs/')) {
$this->markTestSkipped('Mustache spec submodule not initialized: run "git submodule update --init"');
}
$this->assertTrue(true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @group lambdas
* @group functional
*/
class Mustache_Test_FiveThree_Functional_PartialLambdaIndentTest extends PHPUnit_Framework_TestCase
class Mustache_Test_FiveThree_Functional_PartialLambdaIndentTest extends \PHPUnit\Framework\TestCase
{
public function testLambdasInsidePartialsAreIndentedProperly()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @group lambdas
* @group functional
*/
class Mustache_Test_FiveThree_Functional_StrictCallablesTest extends PHPUnit_Framework_TestCase
class Mustache_Test_FiveThree_Functional_StrictCallablesTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider callables
Expand Down
2 changes: 1 addition & 1 deletion test/Mustache/Test/Functional/CallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @group magic_methods
* @group functional
*/
class Mustache_Test_Functional_CallTest extends PHPUnit_Framework_TestCase
class Mustache_Test_Functional_CallTest extends \PHPUnit\Framework\TestCase
{
public function testCallEatsContext()
{
Expand Down
Loading