diff --git a/.travis.yml b/.travis.yml index 7686fb2d4..23ccb125a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_script: - if [[ ! -f codecept.phar ]]; then wget http://codeception.com/codecept.phar; fi script: - if [[ -f codecept.phar ]]; then php codecept.phar build; fi -- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip Install; fi +- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi - if [[ $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi - grunt lint notifications: diff --git a/tests/Install.suite.dist.yml b/tests/install.suite.dist.yml similarity index 100% rename from tests/Install.suite.dist.yml rename to tests/install.suite.dist.yml diff --git a/tests/Install/AutoinstallCept.php b/tests/install/AutoinstallCept.php similarity index 100% rename from tests/Install/AutoinstallCept.php rename to tests/install/AutoinstallCept.php diff --git a/tests/Install/InstallCept.php b/tests/install/InstallCept.php similarity index 100% rename from tests/Install/InstallCept.php rename to tests/install/InstallCept.php diff --git a/tests/Install/_bootstrap.php b/tests/install/_bootstrap.php similarity index 100% rename from tests/Install/_bootstrap.php rename to tests/install/_bootstrap.php diff --git a/tests/Unit.suite.dist.yml b/tests/unit.suite.dist.yml similarity index 100% rename from tests/Unit.suite.dist.yml rename to tests/unit.suite.dist.yml diff --git a/tests/Unit/_bootstrap.php b/tests/unit/_bootstrap.php similarity index 100% rename from tests/Unit/_bootstrap.php rename to tests/unit/_bootstrap.php diff --git a/tests/Unit/classes/context/ContextTest.php b/tests/unit/classes/ContextTest.php similarity index 100% rename from tests/Unit/classes/context/ContextTest.php rename to tests/unit/classes/ContextTest.php diff --git a/tests/Unit/classes/file/FileHandlerTest.php b/tests/unit/classes/FileHandlerTest.php similarity index 100% rename from tests/Unit/classes/file/FileHandlerTest.php rename to tests/unit/classes/FileHandlerTest.php diff --git a/tests/Unit/classes/frontendfile/FrontEndFileHandlerTest.php b/tests/unit/classes/FrontEndFileHandlerTest.php similarity index 100% rename from tests/Unit/classes/frontendfile/FrontEndFileHandlerTest.php rename to tests/unit/classes/FrontEndFileHandlerTest.php diff --git a/tests/Unit/classes/security/SecurityTest.php b/tests/unit/classes/SecurityTest.php similarity index 100% rename from tests/Unit/classes/security/SecurityTest.php rename to tests/unit/classes/SecurityTest.php diff --git a/tests/Unit/classes/template/TemplateHandlerTest.php b/tests/unit/classes/TemplateHandlerTest.php similarity index 90% rename from tests/Unit/classes/template/TemplateHandlerTest.php rename to tests/unit/classes/TemplateHandlerTest.php index e3168ad2f..a2d47e048 100644 --- a/tests/Unit/classes/template/TemplateHandlerTest.php +++ b/tests/unit/classes/TemplateHandlerTest.php @@ -1,15 +1,15 @@ 10">Link', @@ -98,12 +98,12 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test // #include array( '
This is another dummy
', - '?>compile(\'tests/Unit/classes/template\',\'sample.html\') ?>
This is another dummy
' + '?>compile(\'tests/unit/classes/template\',\'sample.html\') ?>
This is another dummy
' ), // array( '
This is another dummy
', - '?>compile(\'tests/Unit/classes\',\'sample.html\') ?>
This is another dummy
' + '?>compile(\'tests/unit/classes\',\'sample.html\') ?>
This is another dummy
' ), // array( @@ -113,12 +113,12 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test // array( '', - '?>' + '?>' ), // array( '', - '?>' + '?>' ), // array( @@ -128,12 +128,12 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test // array( '', - '?>' + '?>' ), // array( '', - '?>' + '?>' ), // comment array( @@ -148,7 +148,7 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test // relative path1 array( '', - '?>' + '?>' ), // relative path2 array( @@ -213,7 +213,7 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test // issue 584 array( 'mobile', - PHP_EOL . 'if($__Context->oBodex->display_extra_images[\'mobile\'] && $__Context->arr_extra && $__Context->arr_extra->bodex->mobile){ ?>mobile' + PHP_EOL . 'if($__Context->oBodex->display_extra_images[\'mobile\'] && $__Context->arr_extra && $__Context->arr_extra->bodex->mobile){ ?>mobile' ), // issue 831 array( @@ -223,7 +223,7 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test // issue 746 array( '', - '?>' + '?>' ), // issue 696 array( @@ -233,35 +233,35 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test // https://github.com/xpressengine/xe-core/issues/1510 array( '', - PHP_EOL . 'if($__Context->foo->bar){ ?>' + PHP_EOL . 'if($__Context->foo->bar){ ?>' ), // https://github.com/xpressengine/xe-core/issues/1510 array( 'a!@#$%^&*()_-=[]{}?/', - PHP_EOL . 'if($__Context->foo->bar > 100){ ?>a!@#$%^&*()_-=[]{}?/' + PHP_EOL . 'if($__Context->foo->bar > 100){ ?>a!@#$%^&*()_-=[]{}?/' ), // https://github.com/xpressengine/xe-core/issues/1510 array( '', - PHP_EOL . 'if($__Context->foo->bar){ ?>' + PHP_EOL . 'if($__Context->foo->bar){ ?>' ), // https://github.com/xpressengine/xe-core/issues/1510 array( '', - PHP_EOL . 'if(!$__Context->module_info->title){ ?>' + PHP_EOL . 'if(!$__Context->module_info->title){ ?>' ), // https://github.com/xpressengine/xe-core/issues/1510 array( '', - PHP_EOL . 'if($__Context->mi->title){ ?>mi->use){ ?> class="tmp_class" src="/xe/tests/Unit/classes/img/common/blank.gif" />' + PHP_EOL . 'if($__Context->mi->title){ ?>mi->use){ ?> class="tmp_class" src="/xe/tests/unit/classes/img/common/blank.gif" />' ), array( ' alt', - '?> foo->bar){ ?>alt' + '?> foo->bar){ ?>alt' ), array( '' . "\n" . ' alt', - '?>' . PHP_EOL . ' foo->bar){ ?>alt' + '?>' . PHP_EOL . ' foo->bar){ ?>alt' ), array( 'asf ', @@ -269,44 +269,40 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test ), array( '', - '?>' + '?>' ), array( 'asdf src="../img/img.gif" asdf src asdf src="../img/img.gif" asdf', - '?>asdf src="../img/img.gif" asdf src asdf src="../img/img.gif" asdf' + '?>asdf src="../img/img.gif" asdf src asdf src="../img/img.gif" asdf' ), array( 'asdf src="../img/img.gif" asdf', '?>asdf src="../img/img.gif" asdf' ), ); + + foreach ($tests as $test) + { + $tmpl = new TemplateHandlerWrapper; + $tmpl->init(__DIR__ . '/template', 'no_file.html'); + $result = $tmpl->parse($test[0]); + $this->assertEquals($this->prefix . $test[1], $result); + } } - /** - * @dataProvider provider - */ - public function testParse($tpl, $expected) + public function testParseNoContent() { $tmpl = new TemplateHandlerWrapper; - $tmpl->init(dirname(__FILE__), 'no_file.html'); + $tmpl->init(__DIR__ . '/template', 'no_file.html'); $result = $tmpl->parse($tpl); - $this->assertEquals($result, $this->prefix.$expected); - } - - public function testParse2() - { - $tmpl = new TemplateHandlerWrapper; - $tmpl->init(dirname(__FILE__), 'no_file.html'); - $result = $tmpl->parse($tpl); - - $this->assertEquals($result, ''); + $this->assertEquals('', $result); } public function testCompileDirect() { $tmpl = TemplateHandler::getInstance(); - $result = $tmpl->compileDirect(dirname(__FILE__), 'sample.html'); + $result = $tmpl->compileDirect(__DIR__ . '/template', 'sample.html'); $result = trim($result); $this->assertEquals($result, $this->prefix.PHP_EOL.'if($__Context->has_blog){ ?>Taggon\'s blog'.PHP_EOL.''); diff --git a/tests/Unit/classes/validator/ValidatorTest.php b/tests/unit/classes/ValidatorTest.php similarity index 95% rename from tests/Unit/classes/validator/ValidatorTest.php rename to tests/unit/classes/ValidatorTest.php index cc21d28db..10b35ec60 100644 --- a/tests/Unit/classes/validator/ValidatorTest.php +++ b/tests/unit/classes/ValidatorTest.php @@ -131,7 +131,7 @@ class ValidatorTest extends \Codeception\TestCase\Test public function testCustomRuleXml() { - $vd = new Validator(dirname(__FILE__).'/customrule.xml'); + $vd = new Validator(__DIR__ . '/validator/customrule.xml'); $this->assertTrue($vd->validate(array('regex_field' => 'abc'))); $this->assertFalse($vd->validate(array('regex_field' => 'ABC'))); @@ -172,7 +172,7 @@ class ValidatorTest extends \Codeception\TestCase\Test public function testConditionXml() { - $vd = new Validator(dirname(__FILE__).'/condition.xml'); + $vd = new Validator(__DIR__ . '/validator/condition.xml'); $data = array('greeting1'=>'hello'); $this->assertTrue($vd->validate($data)); @@ -185,15 +185,15 @@ class ValidatorTest extends \Codeception\TestCase\Test $this->assertTrue($vd->validate($data)); // javascript - $vd->setCacheDir(dirname(__FILE__)); + $vd->setCacheDir(__DIR__ . '/validator'); $js = $vd->getJsPath(); - $this->assertFileEquals($js, dirname(__FILE__).'/condition.en.js'); + $this->assertFileEquals($js, __DIR__ . '/validator/condition.en.js'); } protected function tearDown() { // remove cache directory - $cache_dir = dirname(__FILE__).'/ruleset'; + $cache_dir = __DIR__ . '/validator/ruleset'; if(is_dir($cache_dir)) { $files = (array)glob($cache_dir.'/*'); diff --git a/tests/Unit/classes/template/css/style.css b/tests/unit/classes/template/css/style.css similarity index 100% rename from tests/Unit/classes/template/css/style.css rename to tests/unit/classes/template/css/style.css diff --git a/tests/Unit/classes/template/sample.html b/tests/unit/classes/template/sample.html similarity index 100% rename from tests/Unit/classes/template/sample.html rename to tests/unit/classes/template/sample.html diff --git a/tests/Unit/classes/validator/condition.en.js b/tests/unit/classes/validator/condition.en.js similarity index 100% rename from tests/Unit/classes/validator/condition.en.js rename to tests/unit/classes/validator/condition.en.js diff --git a/tests/Unit/classes/validator/condition.xml b/tests/unit/classes/validator/condition.xml similarity index 100% rename from tests/Unit/classes/validator/condition.xml rename to tests/unit/classes/validator/condition.xml diff --git a/tests/Unit/classes/validator/customrule.xml b/tests/unit/classes/validator/customrule.xml similarity index 100% rename from tests/Unit/classes/validator/customrule.xml rename to tests/unit/classes/validator/customrule.xml diff --git a/tests/Unit/classes/validator/insertDocument.xml b/tests/unit/classes/validator/insertDocument.xml similarity index 100% rename from tests/Unit/classes/validator/insertDocument.xml rename to tests/unit/classes/validator/insertDocument.xml diff --git a/tests/Unit/classes/validator/login.xml b/tests/unit/classes/validator/login.xml similarity index 100% rename from tests/Unit/classes/validator/login.xml rename to tests/unit/classes/validator/login.xml diff --git a/tests/Unit/framework/ConfigTest.php b/tests/unit/framework/ConfigTest.php similarity index 100% rename from tests/Unit/framework/ConfigTest.php rename to tests/unit/framework/ConfigTest.php diff --git a/tests/Unit/framework/DateTimeTest.php b/tests/unit/framework/DateTimeTest.php similarity index 100% rename from tests/Unit/framework/DateTimeTest.php rename to tests/unit/framework/DateTimeTest.php diff --git a/tests/Unit/framework/DebugTest.php b/tests/unit/framework/DebugTest.php similarity index 100% rename from tests/Unit/framework/DebugTest.php rename to tests/unit/framework/DebugTest.php diff --git a/tests/Unit/framework/IpFilterTest.php b/tests/unit/framework/IpFilterTest.php similarity index 100% rename from tests/Unit/framework/IpFilterTest.php rename to tests/unit/framework/IpFilterTest.php diff --git a/tests/Unit/framework/LangTest.php b/tests/unit/framework/LangTest.php similarity index 100% rename from tests/Unit/framework/LangTest.php rename to tests/unit/framework/LangTest.php diff --git a/tests/Unit/FuncIncTest.php b/tests/unit/functions/LegacyTest.php similarity index 89% rename from tests/Unit/FuncIncTest.php rename to tests/unit/functions/LegacyTest.php index bcd0e364b..65550545f 100644 --- a/tests/Unit/FuncIncTest.php +++ b/tests/unit/functions/LegacyTest.php @@ -1,10 +1,10 @@

IFrame

', @@ -59,14 +59,11 @@ class FuncIncTest extends \Codeception\TestCase\Test 'dummy' ) ); - } - - /** - * @dataProvider provider - */ - public function testXss($source, $expected) - { - $result = removeHackTag($source); - $this->assertEquals($result, $expected); + + foreach ($tests as $test) + { + $result = removeHackTag($test[0]); + $this->assertEquals($test[1], $result); + } } }