test will run sinc php 5.6

This commit is contained in:
uwetews
2016-11-11 23:03:46 +01:00
parent 9bfc85b045
commit b7f845f5a9

View File

@@ -2,166 +2,124 @@
//require_once '../../../../../vendor/autoload.php'; //require_once '../../../../../vendor/autoload.php';
class Base if (version_compare(phpversion(), '5.5.0', '>')) {
{
const TEMPLATE='034_parent.tpl';
public $id=null; class Base
public function __construct($id)
{ {
$this->id=$id; const TEMPLATE = '034_parent.tpl';
}
public function getHTML() public $id = null;
{
return static::class;
}
}
class Child extends Base public function __construct($id)
{
const TEMPLATE='034_child.tpl';
public function getText()
{
return $this->getHTML();
}
}
class BaseClone extends Base
{
}
/*
* @requires PHP 5.5
*/
class InheritanceTest extends PHPUnit_Framework_TestCase
{
protected $smarty;
protected function setUp()
{
chdir(dirname(__FILE__));
$this->smarty=new Smarty();
$this->smarty->setTemplateDir('./templates');
$this->smarty->setCompileDir('./templates_c');
$this->smarty->setCacheDir('./cache');
$this->smarty->caching=false;
}
/**
* @dataProvider providerInheritance
*/
public function testInheritance($elements, $assertions)
{
foreach ($elements as $nr=> $element)
{ {
$this->smarty->assign('e', $element); $this->id = $id;
$this->assertSame($assertions[$nr], $this->smarty->fetch($element::TEMPLATE));
} }
}
/** public function getHTML()
* @dataProvider providerInheritance
*/
public function testInheritanceCaching($elements, $assertions)
{
$this->smarty->caching = true;
foreach ($elements as $nr=> $element)
{ {
$this->smarty->assign('e', $element); return static::class;
$this->assertSame($assertions[$nr], $this->smarty->fetch($element::TEMPLATE));
}
}
/**
* @dataProvider providerInheritance
*/
public function testInheritanceCaching1($elements, $assertions)
{
$this->smarty->caching = true;
foreach ($elements as $nr=> $element)
{
$this->smarty->assign('e', $element);
$stat = $this->smarty->isCached($element::TEMPLATE);
$this->assertSame($assertions[$nr], $this->smarty->fetch($element::TEMPLATE));
$this->assertTrue($stat);
} }
} }
public function providerInheritance() class Child extends Base
{ {
return [ const TEMPLATE = '034_child.tpl';
[
//(#0) This test works as expected public function getText()
[ {
new Base(1), return $this->getHTML();
new Base(2), }
new BaseClone(3), }
], [
'1 Base', class BaseClone extends Base
'2 Base', {
'3 BaseClone',
], }
], [
//(#1) This test works as expected /*
[ * @requires PHP 5.5
new Child(1), */
new BaseClone(2), //This output is right(!)
], [ class InheritanceTest extends PHPUnit_Framework_TestCase
'1 Child', {
'2 BaseClone', protected $smarty;
],
], [ protected function setUp()
//(#2) This test fails {
[ chdir(dirname(__FILE__));
new Child(1), $this->smarty = new Smarty();
new Child(2), $this->smarty->setTemplateDir('./templates');
new BaseClone(3), $this->smarty->setCompileDir('./templates_c');
], [ $this->smarty->setCacheDir('./cache');
'1 Child', $this->smarty->caching = false;
'2 Child', }
'3 BaseClone', //Here the output is "2 Child"
], /**
], [ * @dataProvider providerInheritance
//(#3) This test fails * @requires PHP5.5
[ */
new Child(1), public function testInheritance($elements, $assertions)
new BaseClone(2), {
new Child(3), foreach ($elements as $nr => $element) {
], [ $this->smarty->assign('e', $element);
'1 Child', $this->assertSame($assertions[ $nr ], $this->smarty->fetch($element::TEMPLATE));
'2 BaseClone', }
'3 Child', //Here the output is "2 Child" }
],
], [ /**
//(#4) This test fails * @dataProvider providerInheritance
[ */
new Child(1), public function testInheritanceCaching($elements, $assertions)
new Child(2), {
new BaseClone(3), $this->smarty->caching = true;
new Child(4), foreach ($elements as $nr => $element) {
], [ $this->smarty->assign('e', $element);
'1 Child', $this->assertSame($assertions[ $nr ], $this->smarty->fetch($element::TEMPLATE));
'2 Child', }
'3 BaseClone', //Here the output is also "2 Child" }
'4 Child',
], /**
], [ * @dataProvider providerInheritance
//(#5) This test fails */
[ public function testInheritanceCaching1($elements, $assertions)
new BaseClone(1), {
new Child(2), $this->smarty->caching = true;
new Child(3), foreach ($elements as $nr => $element) {
new BaseClone(4), $this->smarty->assign('e', $element);
], [ $stat = $this->smarty->isCached($element::TEMPLATE);
'1 BaseClone', //This output is right(!) $this->assertSame($assertions[ $nr ], $this->smarty->fetch($element::TEMPLATE));
'2 Child', $this->assertTrue($stat);
'3 Child', }
'4 BaseClone', //Here the output is "3 Child" }
],
], public function providerInheritance()
]; {
return [[//(#0) This test works as expected
[new Base(1), new Base(2), new BaseClone(3),], ['1 Base', '2 Base', '3 BaseClone',],],
[//(#1) This test works as expected
[new Child(1), new BaseClone(2), //This output is right(!)
], ['1 Child', '2 BaseClone',],], [//(#2) This test fails
[new Child(1), new Child(2), new BaseClone(3),],
['1 Child', '2 Child', '3 BaseClone',
//Here the output is "2 Child"
],], [//(#3) This test fails
[new Child(1), new BaseClone(2), new Child(3),],
['1 Child', '2 BaseClone', '3 Child',
//Here the output is "2 Child"
],], [//(#4) This test fails
[new Child(1), new Child(2), new BaseClone(3),
new Child(4),],
['1 Child', '2 Child', '3 BaseClone',
//Here the output is also "2 Child"
'4 Child',],], [//(#5) This test fails
[new BaseClone(1), new Child(2),
new Child(3), new BaseClone(4),],
['1 BaseClone',
//This output is right(!)
'2 Child', '3 Child',
'4 BaseClone',
//Here the output is "3 Child"
],],];
}
} }
} }