diff --git a/.gitattributes b/.gitattributes index f54186e54..d6a255849 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,7 +2,5 @@ .gitignore export-ignore /tools/ export-ignore /tests/ export-ignore -/phpDoc/ export-ignore Gruntfile.js export-ignore -package.json export-ignore -.travis.yml export-ignore \ No newline at end of file +.travis.yml export-ignore diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index 5f00d3da3..000000000 --- a/.jshintignore +++ /dev/null @@ -1,9 +0,0 @@ -common/js/jquery*.js -common/js/modernizr.js -common/js/xe.js -common/js/x.js -common/js/*.min.js -common/js/unittest/* -common/js/plugins/* -common/js/foggyLayer.js -common/js/html5.js diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index ae1b55f2c..000000000 --- a/.jshintrc +++ /dev/null @@ -1,68 +0,0 @@ -{ - "globalstrict": false, - "undef": false, - "eqeqeq": false, - "browser": true, - "devel": true, - "jquery": true, - "evil": true, - "globals": { - "window": true, - "current_url": true, - "exec_json": true, - "exec_xml": true, - "procFilter": true, - "xe": true, - "request_uri": true, - "xAddEventListener": false, - "xResizeEvent": false, - "xScrollEvent": false, - "xAppendChild": false, - "xClientHeight": false, - "xClientWidth": false, - "xCreateElement": false, - "xDef": false, - "xDeleteCookie": false, - "xDisplay": false, - "xEvent": false, - "xFirstChild": false, - "xGetBodyWidth": false, - "xGetBodyHeight": false, - "xGetComputedStyle": false, - "xGetCookie": false, - "xGetElementById": false, - "xGetElementsByAttribute": false, - "xGetElementsByClassName": false, - "xGetElementsByTagName": false, - "xGetURLArguments": false, - "xHeight": false, - "xHex": false, - "xHide": false, - "xInnerHtml": false, - "xLeft": false, - "xMoveTo": false, - "xName": false, - "xNextSib": false, - "xNum": false, - "xOffsetLeft": false, - "xOffsetTop": false, - "xPad": false, - "xPageX": false, - "xPageY": false, - "xParent": false, - "xPreventDefault": false, - "xPrevSib": false, - "xRemoveEventListener": false, - "xResizeTo": false, - "xScrollLeft": false, - "xScrollTop": false, - "xSetCookie": false, - "xShow": false, - "xStr": false, - "xTop": false, - "xVisibility": false, - "xWidth": false, - "xZIndex": false, - "xStopPropagation": false - } -} diff --git a/.travis.yml b/.travis.yml index 0a63e8c41..7c1edacad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,17 +12,16 @@ matrix: fast_finish: true sudo: false before_script: -- npm install -g grunt-cli -- npm install -- mysql -e "CREATE DATABASE xe_test;" -- echo "USE mysql;\nUPDATE user SET password=PASSWORD('travis') WHERE user='travis';\nFLUSH PRIVILEGES;\n" | mysql -u root +- npm install grunt grunt-cli grunt-contrib-jshint grunt-contrib-csslint grunt-phplint --save-dev +- mysql -u root -e "CREATE DATABASE rhymix" +- mysql -u root -e "SET PASSWORD FOR 'travis'@'localhost' = PASSWORD('travis')" - php -S localhost:8000 & - if [ $(phpenv version-name) == "5.3" ]; then touch codecept.phar; fi - if [ $(phpenv version-name) == "5.4" ]; then wget http://codeception.com/releases/2.0.16/codecept.phar; fi - if [ ! -f codecept.phar ]; then wget http://codeception.com/codecept.phar; fi script: -- grunt lint - if [ -f codecept.phar ]; then php codecept.phar build; fi - if [ -f codecept.phar ]; then php codecept.phar run -d --fail-fast --env travis; fi +- grunt lint notifications: email: false diff --git a/Gruntfile.js b/Gruntfile.js index 2c894b78e..c2a43256a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,9 +1,6 @@ module.exports = function(grunt) { "use strict"; - var banner = '/*! Copyright (C) NAVER */\n'; - var banner_xe_js = banner + '/**!\n * @concat modernizr.js + common.js + js_app.js + xml_handler.js + xml_js_filter.js\n * @brief XE Common JavaScript\n **/\n'; - grunt.file.defaultEncoding = 'utf8'; grunt.initConfig({ @@ -65,7 +62,6 @@ module.exports = function(grunt) { options: { phpCmd: "php", }, - src: [ "**/*.php", "!files/**", @@ -79,184 +75,10 @@ module.exports = function(grunt) { }, } }); - - function createPackageChecksum(target_file) { - /* https://gist.github.com/onelaview/6475037 */ - var fs = require('fs'); - var crypto = require('crypto'); - var md5 = crypto.createHash('md5'); - var file = grunt.template.process(target_file); - var buffer = fs.readFileSync(file); - md5.update(buffer); - var md5Hash = md5.digest('hex'); - grunt.verbose.writeln('file md5: ' + md5Hash); - - var md5FileName = file + '.md5'; - grunt.file.write(md5FileName, md5Hash); - grunt.verbose.writeln('File "' + md5FileName + '" created.').writeln('...'); - } - - grunt.registerTask('build', '', function(A, B) { - var _only_export = false; - var tasks = ['krzip', 'syndication']; - - if(!A) { - grunt.fail.warn('Undefined build target.'); - } else if(A && !B) { - _only_export = true; - } - - if(!_only_export) { - tasks.push('changed'); - target = A + '...' + B; - version = B; - } else { - target = A; - version = A; - } - - var done = this.async(); - var build_dir = 'build'; - var archive_full = build_dir + '/xe.' + version + '.tar.gz'; - var archive_changed = build_dir + '/xe.' + version + '.changed.tar.gz'; - var diff, target, version; - - var taskDone = function() { - tasks.pop(); - grunt.verbose.writeln('remain tasks : '+tasks.length); - - if(tasks.length === 0) { - grunt.util.spawn({ - cmd: "tar", - args: ['cfz', '../xe.'+version+'.tar.gz', './'], - opts: { - cwd: 'build/xe', - cache: false - } - }, function (error, result, code) { - grunt.log.ok('Archived(full) : ' + build_dir + '/xe.'+version+'.tar.gz'); - createPackageChecksum(build_dir + '/xe.'+version+'.tar.gz'); - - grunt.util.spawn({ - cmd: "zip", - args: ['-r', '../xe.'+version+'.zip', './'], - opts: { - cwd: 'build/xe', - cache: false - } - }, function (error, result, code) { - grunt.log.ok('Archived(full) : ' + build_dir + '/xe.'+version+'.zip'); - createPackageChecksum(build_dir + '/xe.'+version+'.zip'); - - grunt.file.delete('build/xe'); - grunt.file.delete('build/temp.full.tar'); - - grunt.util.spawn({ - cmd: "git", - args: ['diff', '--name-status', target] - }, function (error, result, code) { - var fs = require('fs'); - result = 'Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R).' + grunt.util.linefeed + result; - grunt.file.write(build_dir + '/CHANGED.' + version + '.txt', result); - - grunt.log.ok('Done!'); - }); - - }); - }); - } - }; - - if(grunt.file.isDir(build_dir)) { - grunt.file.delete(build_dir); - } - grunt.file.mkdir(build_dir); - grunt.file.mkdir(build_dir + '/xe'); - - grunt.log.subhead('Archiving...'); - grunt.log.writeln('Target : ' + target); - - grunt.util.spawn({ - cmd: "git", - args: ['archive', '--output=build/temp.full.tar', version, '.'] - }, function (error, result, code){ - if(!_only_export) { - // changed - grunt.util.spawn({ - cmd: "git", - args: ['diff', '--name-only', '--diff-filter' ,'ACM', target] - }, function (error, result, code) { - diff = result.stdout; - - if(diff) { - diff = diff.split(grunt.util.linefeed); - } - - // changed - if(diff.length) { - var args_tar = ['archive', '-o', 'build/xe.'+version+'.changed.tar.gz', version]; - var args_zip = ['archive', '-o', 'build/xe.'+version+'.changed.zip', version]; - args_tar = args_tar.concat(diff); - args_zip = args_zip.concat(diff); - - grunt.util.spawn({ - cmd: "git", - args: args_tar - }, function (error, result, code) { - grunt.log.ok('Archived(changed) : ' + build_dir + '/xe.'+version+'.changed.tar.gz'); - createPackageChecksum(build_dir + '/xe.'+version+'.changed.tar.gz'); - - grunt.util.spawn({ - cmd: "git", - args: args_zip - }, function (error, result, code) { - grunt.log.ok('Archived(changed) : ' + build_dir + '/xe.'+version+'.changed.zip'); - createPackageChecksum(build_dir + '/xe.'+version+'.changed.zip'); - - taskDone(); - }); - }); - } else { - taskDone(); - } - }); - } - - // full - grunt.util.spawn({ - cmd: "tar", - args: ['xf', 'build/temp.full.tar', '-C', 'build/xe'] - }, function (error, result, code) { - // krzip - grunt.util.spawn({ - cmd: "git", - args: ['clone', '-b', 'master', 'git@github.com:xpressengine/xe-module-krzip.git', 'build/xe/modules/krzip'] - }, function (error, result, code) { - grunt.file.delete('build/xe/modules/krzip/.git'); - taskDone(); - }); - - // syndication - grunt.util.spawn({ - cmd: "git", - args: ['clone', '-b', 'master', 'git@github.com:xpressengine/xe-module-syndication.git', 'build/xe/modules/syndication'] - }, function (error, result, code) { - grunt.file.delete('build/xe/modules/syndication/.git'); - taskDone(); - }); - }); - }); - }); - - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-csslint'); - grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-phplint'); - - grunt.registerTask('default', ['jshint', 'csslint']); + grunt.registerTask('lint', ['jshint', 'csslint', 'phplint']); - grunt.registerTask('minify', ['jshint', 'csslint', 'clean', 'concat', 'uglify', 'cssmin']); }; diff --git a/README.md b/README.md index f83e80677..2f02a3ab4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -RhymiX -====== +[![RhymiX](https://cloud.githubusercontent.com/assets/8565457/12227560/ba15b514-b871-11e5-802a-d5e88db2e393.png)](https://www.rhymix.org) RhymiX(라이믹스)는 누구든지 쉽고 자유롭게 독립적인 홈페이지를 만들어 자신을 표현하고 커뮤니티를 키워나갈 수 있도록 돕기 위한 CMS(content management system)입니다. diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 483ab7fc7..8e59a37d3 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -366,13 +366,14 @@ class Context $session_id = $_COOKIE[$session_name]; } - if($session_id !== NULL || $this->db_info->cache_friendly != 'Y') + if($session_id !== NULL || $this->db_info->delay_session != 'Y') { $this->setCacheControl(0, false); session_start(); } else { + ob_start(); $this->setCacheControl(-1, true); register_shutdown_function(array($this, 'checkSessionStatus')); $_SESSION = array(); diff --git a/config/config.inc.php b/config/config.inc.php index e3bfb3934..dd8090ff6 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -9,11 +9,11 @@ */ if(version_compare(PHP_VERSION, '5.4.0', '<')) { - @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); + @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING); } else { - @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); + @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING ^ E_STRICT); } if(!defined('__XE__')) @@ -133,7 +133,7 @@ if(!defined('__DEBUG__')) * 4: output DB query history * */ - define('__DEBUG__', 1); + define('__DEBUG__', 0); } if(!defined('__DEBUG_OUTPUT__')) diff --git a/modules/addon/addon.controller.php b/modules/addon/addon.controller.php index d1eb0781a..241d10534 100644 --- a/modules/addon/addon.controller.php +++ b/modules/addon/addon.controller.php @@ -80,7 +80,6 @@ class addonController extends addon { // Add-on module for use in creating the cache file $buff = array('getInsertedAddons($site_srl, $gtype); foreach($addon_list as $addon => $val) @@ -136,7 +135,6 @@ class addonController extends addon $buff[] = '$addon_time_log->called_extension = "' . $addon . '";'; $buff[] = 'writeSlowlog("addon",$after_time-$before_time,$addon_time_log);'; } - $buff[] = 'ob_end_flush();'; $addon_path = _XE_PATH_ . 'files/cache/addons/'; FileHandler::makeDir($addon_path); $addon_file = $addon_path . ($gtype == 'site' ? $site_srl : '') . $type . '.acivated_addons.cache.php'; diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index cac6133cc..4841befd1 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -72,7 +72,7 @@ class adminAdminView extends admin Context::set('use_spaceremover', $db_info->use_spaceremover ? $db_info->use_spaceremover : 'Y'); //not use Context::set('qmail_compatibility', $db_info->qmail_compatibility == 'Y' ? 'Y' : 'N'); Context::set('minify_scripts', $db_info->minify_scripts ?: 'common'); - Context::set('cache_friendly', $db_info->cache_friendly == 'Y' ? 'Y' : 'N'); + Context::set('delay_session', $db_info->delay_session == 'Y' ? 'Y' : 'N'); Context::set('use_db_session', $db_info->use_db_session == 'N' ? 'N' : 'Y'); Context::set('use_mobile_view', $db_info->use_mobile_view == 'Y' ? 'Y' : 'N'); Context::set('use_ssl', $db_info->use_ssl ? $db_info->use_ssl : "none"); diff --git a/modules/admin/lang/lang.xml b/modules/admin/lang/lang.xml index 3daf96729..bdbdd5c5b 100644 --- a/modules/admin/lang/lang.xml +++ b/modules/admin/lang/lang.xml @@ -785,17 +785,15 @@ - - - - - - + + + + - - 이 옵션을 선택할 경우 방문자 수 및 조회수 집계가 정확하지 않을 수 있습니다.]]> - Selecting this option may cause view counts and visitor counts to become inaccurate.]]> - このオプションを選択した場合、訪問者数とヒット集計が正確でない場合があります。]]> + + 이 옵션을 선택할 경우 방문자 수 및 조회수 집계가 정확하게 이루어지지 않을 수 있습니다.]]> + Selecting this option may cause view counts and visitor counts to become inaccurate.]]> + このオプションを選択した場合、訪問者数とヒット集計が正確でない場合があります。]]> diff --git a/modules/admin/tpl/config_general.html b/modules/admin/tpl/config_general.html index 29e5e01ee..857a23e98 100644 --- a/modules/admin/tpl/config_general.html +++ b/modules/admin/tpl/config_general.html @@ -225,6 +225,15 @@ +
+ +
+ + +
+

{$lang->about_delay_session}

+
+
@@ -235,15 +244,6 @@

{$lang->about_minify_scripts}

-
- -
- - -
-

{$lang->about_cache_friendly}

-
-
diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 7427744d0..14b46e2d2 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -910,8 +910,14 @@ class documentItem extends Object if(!file_exists($tmp_file)) continue; else { - list($_w, $_h, $_t, $_a) = @getimagesize($tmp_file); - if($_w<$width || $_h<$height) continue; + if($is_img = @getimagesize($tmp_file)) + { + list($_w, $_h, $_t, $_a) = $is_img; + } + else + { + continue; + } $source_file = $tmp_file; $is_tmp_file = true; diff --git a/modules/install/install.admin.controller.php b/modules/install/install.admin.controller.php index 4c4525b3a..45ac2f7b8 100644 --- a/modules/install/install.admin.controller.php +++ b/modules/install/install.admin.controller.php @@ -96,19 +96,20 @@ class installAdminController extends install $qmail_compatibility = Context::get('qmail_compatibility'); if($qmail_compatibility!='Y') $qmail_compatibility = 'N'; + $delay_session = Context::get('delay_session'); + if($delay_session!='Y') $delay_session = 'N'; + unset($db_info->cache_friendly); + $minify_scripts = Context::get('minify_scripts'); if(!$minify_scripts) $minify_scripts = 'common'; - $cache_friendly = Context::get('cache_friendly'); - if($cache_friendly!='Y') $cache_friendly = 'N'; - $use_html5 = Context::get('use_html5'); if(!$use_html5) $use_html5 = 'N'; $db_info->default_url = $default_url; $db_info->qmail_compatibility = $qmail_compatibility; $db_info->minify_scripts = $minify_scripts; - $db_info->cache_friendly = $cache_friendly; + $db_info->delay_session = $delay_session; $db_info->use_db_session = $use_db_session; $db_info->use_rewrite = $use_rewrite; $db_info->use_sso = $use_sso; diff --git a/package.json b/package.json deleted file mode 100644 index f692948b2..000000000 --- a/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "RhymiX", - "author": "NAVER, RhymiX Developers and Contributors", - "license": "GNU LGPL", - "repository": { - "type": "git", - "url": "git://github.com/rhymix/rhymix.git" - }, - "bugs": { - "url": "https://github.com/rhymix/rhymix/issues" - }, - "devDependencies": { - "grunt": "^0.4.5", - "grunt-contrib-clean": "^0.5.0", - "grunt-contrib-concat": "^0.3.0", - "grunt-contrib-csslint": "~0.3.0", - "grunt-contrib-cssmin": "^0.7.0", - "grunt-contrib-jshint": "~0.10.0", - "grunt-contrib-uglify": "^0.4.1", - "grunt-phplint": "~0.0.3" - }, - "main": "Gruntfile.js", - "scripts": { - "test": "grunt" - } -} diff --git a/tests/Install.suite.dist.yml b/tests/Install.suite.dist.yml index b217a1c35..5bbbce4ff 100644 --- a/tests/Install.suite.dist.yml +++ b/tests/Install.suite.dist.yml @@ -5,11 +5,11 @@ modules: PhpBrowser: url: 'http://localhost:8000/' DbDropTablesHelper: - dsn: 'mysql:host=127.0.0.1;dbname=xe_test' + dsn: 'mysql:host=localhost;dbname=rhymix' user: 'root' password: 'root' Db: - dsn: 'mysql:host=127.0.0.1;dbname=xe_test' + dsn: 'mysql:host=localhost;dbname=rhymix' user: 'root' password: 'root' cleanup: true @@ -18,11 +18,11 @@ env: modules: config: Db: - dsn: 'mysql:host=127.0.0.1;dbname=xe_test' + dsn: 'mysql:host=localhost;dbname=rhymix' user: 'travis' password: 'travis' cleanup: true DbDropTablesHelper: - dsn: 'mysql:host=127.0.0.1;dbname=xe_test' + dsn: 'mysql:host=localhost;dbname=rhymix' user: 'travis' password: 'travis' diff --git a/tests/Install/AutoinstallCept.php b/tests/Install/AutoinstallCept.php index 463818eab..0a4240838 100644 --- a/tests/Install/AutoinstallCept.php +++ b/tests/Install/AutoinstallCept.php @@ -28,7 +28,7 @@ $install_config = array( 'db_userid' => $dbinfo['user'], 'db_password' => $dbinfo['password'], 'db_database' => $dbinfo['dbname'], - 'db_table_prefix' =>'xe_', + 'db_table_prefix' =>'rx', 'db_charset' => 'utf8', 'use_rewrite' =>'N', 'time_zone' =>'0900', diff --git a/tests/Install/InstallCept.php b/tests/Install/InstallCept.php index daaf62e98..b574fdb22 100644 --- a/tests/Install/InstallCept.php +++ b/tests/Install/InstallCept.php @@ -14,7 +14,7 @@ $dbinfo = [ 'type' => $db_type, 'user' => $db_config['user'], 'password' => $db_config['password'], - 'dbname' => 'xe_install', + 'dbname' => 'rhymix', 'port' => ((isset($db_config['port']) && $db_config['port'])?: 3306), ]; foreach($dsn as $piece) { @@ -27,7 +27,7 @@ if(\Filehandler::exists(_XE_PATH_ . 'config/install.config.php')) { } // Step 1 : License Agreement -$I->wantTo('Install XE Core'); +$I->wantTo('Install RhymiX'); $I->amOnPage('/index.php?l=ko'); $I->setCookie('l', 'ko'); $I->seeElement('//div[@id="progress"]/ul/li[1][@class="active"]'); @@ -50,7 +50,7 @@ $I->submitForm('#body', [ 'db_userid' => $dbinfo['user'], 'db_password' => $dbinfo['password'], 'db_database' => $dbinfo['dbname'], - 'db_table_prefix' => 'xe' + 'db_table_prefix' => 'rx' ]); // Step 4 : Create Admin Account diff --git a/tests/Install/InstallTester.php b/tests/Install/InstallTester.php deleted file mode 100644 index c40651039..000000000 --- a/tests/Install/InstallTester.php +++ /dev/null @@ -1,2433 +0,0 @@ -haveInDatabase('users', array('name' => 'miles', 'email' => 'miles@davis.com')); - * ?> - * ``` - * - * @param $table - * @param array $data - * - * @return integer $id - * @see \Codeception\Module\Db::haveInDatabase() - */ - public function haveInDatabase($table, $data) { - return $this->scenario->runStep(new \Codeception\Step\Action('haveInDatabase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if a row with given column values exists. - * Provide table name and column values. - * - * Example: - * - * ``` php - * seeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); - * - * ``` - * Will generate: - * - * ``` sql - * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' - * ``` - * Fails if no such user found. - * - * @param $table - * @param array $criteria - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\Db::seeInDatabase() - */ - public function canSeeInDatabase($table, $criteria = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInDatabase', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if a row with given column values exists. - * Provide table name and column values. - * - * Example: - * - * ``` php - * seeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); - * - * ``` - * Will generate: - * - * ``` sql - * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' - * ``` - * Fails if no such user found. - * - * @param $table - * @param array $criteria - * @see \Codeception\Module\Db::seeInDatabase() - */ - public function seeInDatabase($table, $criteria = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInDatabase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Effect is opposite to ->seeInDatabase - * - * Checks if there is no record with such column values in database. - * Provide table name and column values. - * - * Example: - * - * ``` php - * dontSeeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); - * - * ``` - * Will generate: - * - * ``` sql - * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' - * ``` - * Fails if such user was found. - * - * @param $table - * @param array $criteria - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\Db::dontSeeInDatabase() - */ - public function cantSeeInDatabase($table, $criteria = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInDatabase', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Effect is opposite to ->seeInDatabase - * - * Checks if there is no record with such column values in database. - * Provide table name and column values. - * - * Example: - * - * ``` php - * dontSeeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); - * - * ``` - * Will generate: - * - * ``` sql - * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' - * ``` - * Fails if such user was found. - * - * @param $table - * @param array $criteria - * @see \Codeception\Module\Db::dontSeeInDatabase() - */ - public function dontSeeInDatabase($table, $criteria = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInDatabase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Fetches a single column value from a database. - * Provide table name, desired column and criteria. - * - * Example: - * - * ``` php - * grabFromDatabase('users', 'email', array('name' => 'Davert')); - * - * ``` - * - * @version 1.1 - * - * @param $table - * @param $column - * @param array $criteria - * - * @return mixed - * @see \Codeception\Module\Db::grabFromDatabase() - */ - public function grabFromDatabase($table, $column, $criteria = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabFromDatabase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Sets the HTTP header to the passed value - which is used on - * subsequent HTTP requests through PhpBrowser. - * - * Example: - * ```php - * setHeader('X-Requested-With', 'Codeception'); - * $I->amOnPage('test-headers.php'); - * ?> - * ``` - * - * @param string $name the name of the request header - * @param string $value the value to set it to for subsequent - * requests - * @see \Codeception\Module\PhpBrowser::setHeader() - */ - public function setHeader($name, $value) { - return $this->scenario->runStep(new \Codeception\Step\Action('setHeader', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Deletes the header with the passed name. Subsequent requests - * will not have the deleted header in its request. - * - * Example: - * ```php - * setHeader('X-Requested-With', 'Codeception'); - * $I->amOnPage('test-headers.php'); - * // ... - * $I->deleteHeader('X-Requested-With'); - * $I->amOnPage('some-other-page.php'); - * ?> - * ``` - * - * @param string $name the name of the header to delete. - * @see \Codeception\Module\PhpBrowser::deleteHeader() - */ - public function deleteHeader($name) { - return $this->scenario->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Authenticates user for HTTP_AUTH - * - * @param $username - * @param $password - * @see \Codeception\Module\PhpBrowser::amHttpAuthenticated() - */ - public function amHttpAuthenticated($username, $password) { - return $this->scenario->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opens the page for the given relative URI. - * - * ``` php - * amOnPage('/'); - * // opens /register page - * $I->amOnPage('/register'); - * ?> - * ``` - * - * @param $page - * @see \Codeception\Module\PhpBrowser::amOnPage() - */ - public function amOnPage($page) { - return $this->scenario->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Open web page at the given absolute URL and sets its hostname as the base host. - * - * ``` php - * amOnUrl('http://codeception.com'); - * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart - * ?> - * ``` - * @see \Codeception\Module\PhpBrowser::amOnUrl() - */ - public function amOnUrl($url) { - return $this->scenario->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Changes the subdomain for the 'url' configuration parameter. - * Does not open a page; use `amOnPage` for that. - * - * ``` php - * amOnSubdomain('user'); - * $I->amOnPage('/'); - * // moves to http://user.mysite.com/ - * ?> - * ``` - * - * @param $subdomain - * - * @return mixed - * @see \Codeception\Module\PhpBrowser::amOnSubdomain() - */ - public function amOnSubdomain($subdomain) { - return $this->scenario->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Low-level API method. - * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly - * - * Example: - * - * ``` php - * executeInGuzzle(function (\GuzzleHttp\Client $client) { - * $client->get('/get', ['query' => ['foo' => 'bar']]); - * }); - * ?> - * ``` - * - * It is not recommended to use this command on a regular basis. - * If Codeception lacks important Guzzle Client methods, implement them and submit patches. - * - * @param callable $function - * @see \Codeception\Module\PhpBrowser::executeInGuzzle() - */ - public function executeInGuzzle($function) { - return $this->scenario->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Perform a click on a link or a button, given by a locator. - * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. - * For buttons, the "value" attribute, "name" attribute, and inner text are searched. - * For links, the link text is searched. - * For images, the "alt" attribute and inner text of any parent links are searched. - * - * The second parameter is a context (CSS or XPath locator) to narrow the search. - * - * Note that if the locator matches a button of type `submit`, the form will be submitted. - * - * ``` php - * click('Logout'); - * // button of form - * $I->click('Submit'); - * // CSS button - * $I->click('#form input[type=submit]'); - * // XPath - * $I->click('//form/*[@type=submit]'); - * // link in context - * $I->click('Logout', '#nav'); - * // using strict locator - * $I->click(['link' => 'Login']); - * ?> - * ``` - * - * @param $link - * @param $context - * @see \Codeception\Lib\InnerBrowser::click() - */ - public function click($link, $context = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('click', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string. - * Specify a locator as the second parameter to match a specific region. - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up','h1'); // I can suppose it's a signup page - * $I->see('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::see() - */ - public function canSee($text, $selector = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string. - * Specify a locator as the second parameter to match a specific region. - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up','h1'); // I can suppose it's a signup page - * $I->see('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * @see \Codeception\Lib\InnerBrowser::see() - */ - public function see($text, $selector = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('see', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page doesn't contain the text specified. - * Give a locator as the second parameter to match a specific region. - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSee() - */ - public function cantSee($text, $selector = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page doesn't contain the text specified. - * Give a locator as the second parameter to match a specific region. - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * @see \Codeception\Lib\InnerBrowser::dontSee() - */ - public function dontSee($text, $selector = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there's a link with the specified text. - * Give a full URL as the second parameter to match links with that exact URL. - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param $text - * @param null $url - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeLink() - */ - public function canSeeLink($text, $url = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there's a link with the specified text. - * Give a full URL as the second parameter to match links with that exact URL. - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param $text - * @param null $url - * @see \Codeception\Lib\InnerBrowser::seeLink() - */ - public function seeLink($text, $url = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page doesn't contain a link with the given string. - * If the second parameter is given, only links with a matching "href" attribute will be checked. - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * $I->dontSeeLink('Checkout now', '/store/cart.php'); - * ?> - * ``` - * - * @param $text - * @param null $url - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeLink() - */ - public function cantSeeLink($text, $url = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page doesn't contain a link with the given string. - * If the second parameter is given, only links with a matching "href" attribute will be checked. - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * $I->dontSeeLink('Checkout now', '/store/cart.php'); - * ?> - * ``` - * - * @param $text - * @param null $url - * @see \Codeception\Lib\InnerBrowser::dontSeeLink() - */ - public function dontSeeLink($text, $url = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current URI contains the given string. - * - * ``` php - * seeInCurrentUrl('home'); - * // to match: /users/1 - * $I->seeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() - */ - public function canSeeInCurrentUrl($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current URI contains the given string. - * - * ``` php - * seeInCurrentUrl('home'); - * // to match: /users/1 - * $I->seeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() - */ - public function seeInCurrentUrl($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URI doesn't contain the given string. - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() - */ - public function cantSeeInCurrentUrl($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URI doesn't contain the given string. - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() - */ - public function dontSeeInCurrentUrl($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL is equal to the given string. - * Unlike `seeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * seeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() - */ - public function canSeeCurrentUrlEquals($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL is equal to the given string. - * Unlike `seeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * seeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() - */ - public function seeCurrentUrlEquals($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL doesn't equal the given string. - * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * dontSeeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() - */ - public function cantSeeCurrentUrlEquals($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL doesn't equal the given string. - * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. - * - * ``` php - * dontSeeCurrentUrlEquals('/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() - */ - public function dontSeeCurrentUrlEquals($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL matches the given regular expression. - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() - */ - public function canSeeCurrentUrlMatches($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URL matches the given regular expression. - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() - */ - public function seeCurrentUrlMatches($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url doesn't match the given regular expression. - * - * ``` php - * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() - */ - public function cantSeeCurrentUrlMatches($uri) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current url doesn't match the given regular expression. - * - * ``` php - * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() - */ - public function dontSeeCurrentUrlMatches($uri) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Executes the given regular expression against the current URI and returns the first match. - * If no parameters are provided, the full URI is returned. - * - * ``` php - * grabFromCurrentUrl('~$/user/(\d+)/~'); - * $uri = $I->grabFromCurrentUrl(); - * ?> - * ``` - * - * @param null $uri - * - * @internal param $url - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() - */ - public function grabFromCurrentUrl($uri = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the specified checkbox is checked. - * - * ``` php - * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. - * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); - * ?> - * ``` - * - * @param $checkbox - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() - */ - public function canSeeCheckboxIsChecked($checkbox) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the specified checkbox is checked. - * - * ``` php - * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. - * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); - * ?> - * ``` - * - * @param $checkbox - * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() - */ - public function seeCheckboxIsChecked($checkbox) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check that the specified checkbox is unchecked. - * - * ``` php - * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. - * ?> - * ``` - * - * @param $checkbox - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() - */ - public function cantSeeCheckboxIsChecked($checkbox) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Check that the specified checkbox is unchecked. - * - * ``` php - * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms - * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. - * ?> - * ``` - * - * @param $checkbox - * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() - */ - public function dontSeeCheckboxIsChecked($checkbox) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given input field or textarea contains the given value. - * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. - * - * ``` php - * seeInField('Body','Type your comment here'); - * $I->seeInField('form textarea[name=body]','Type your comment here'); - * $I->seeInField('form input[type=hidden]','hidden_value'); - * $I->seeInField('#searchform input','Search'); - * $I->seeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInField() - */ - public function canSeeInField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given input field or textarea contains the given value. - * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. - * - * ``` php - * seeInField('Body','Type your comment here'); - * $I->seeInField('form textarea[name=body]','Type your comment here'); - * $I->seeInField('form input[type=hidden]','hidden_value'); - * $I->seeInField('#searchform input','Search'); - * $I->seeInField('//form/*[@name=search]','Search'); - * $I->seeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::seeInField() - */ - public function seeInField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea doesn't contain the given value. - * For fuzzy locators, the field is matched by label text, CSS and XPath. - * - * ``` php - * dontSeeInField('Body','Type your comment here'); - * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); - * $I->dontSeeInField('form input[type=hidden]','hidden_value'); - * $I->dontSeeInField('#searchform input','Search'); - * $I->dontSeeInField('//form/*[@name=search]','Search'); - * $I->dontSeeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInField() - */ - public function cantSeeInField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that an input field or textarea doesn't contain the given value. - * For fuzzy locators, the field is matched by label text, CSS and XPath. - * - * ``` php - * dontSeeInField('Body','Type your comment here'); - * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); - * $I->dontSeeInField('form input[type=hidden]','hidden_value'); - * $I->dontSeeInField('#searchform input','Search'); - * $I->dontSeeInField('//form/*[@name=search]','Search'); - * $I->dontSeeInField(['name' => 'search'], 'Search'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::dontSeeInField() - */ - public function dontSeeInField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are set on the form matched with the - * passed selector. - * - * ``` php - * seeInFormFields('form[name=myform]', [ - * 'input1' => 'value', - * 'input2' => 'other value', - * ]); - * ?> - * ``` - * - * For multi-select elements, or to check values of multiple elements with the same name, an - * array may be passed: - * - * ``` php - * seeInFormFields('.form-class', [ - * 'multiselect' => [ - * 'value1', - * 'value2', - * ], - * 'checkbox[]' => [ - * 'a checked value', - * 'another checked value', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * seeInFormFields('#form-id', [ - * 'checkbox1' => true, // passes if checked - * 'checkbox2' => false, // passes if unchecked - * ]); - * ?> - * ``` - * - * Pair this with submitForm for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInFormFields() - */ - public function canSeeInFormFields($formSelector, $params) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are set on the form matched with the - * passed selector. - * - * ``` php - * seeInFormFields('form[name=myform]', [ - * 'input1' => 'value', - * 'input2' => 'other value', - * ]); - * ?> - * ``` - * - * For multi-select elements, or to check values of multiple elements with the same name, an - * array may be passed: - * - * ``` php - * seeInFormFields('.form-class', [ - * 'multiselect' => [ - * 'value1', - * 'value2', - * ], - * 'checkbox[]' => [ - * 'a checked value', - * 'another checked value', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * seeInFormFields('#form-id', [ - * 'checkbox1' => true, // passes if checked - * 'checkbox2' => false, // passes if unchecked - * ]); - * ?> - * ``` - * - * Pair this with submitForm for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * @see \Codeception\Lib\InnerBrowser::seeInFormFields() - */ - public function seeInFormFields($formSelector, $params) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are not set on the form matched with - * the passed selector. - * - * ``` php - * dontSeeInFormFields('form[name=myform]', [ - * 'input1' => 'non-existent value', - * 'input2' => 'other non-existent value', - * ]); - * ?> - * ``` - * - * To check that an element hasn't been assigned any one of many values, an array can be passed - * as the value: - * - * ``` php - * dontSeeInFormFields('.form-class', [ - * 'fieldName' => [ - * 'This value shouldn\'t be set', - * 'And this value shouldn\'t be set', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * dontSeeInFormFields('#form-id', [ - * 'checkbox1' => true, // fails if checked - * 'checkbox2' => false, // fails if unchecked - * ]); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() - */ - public function cantSeeInFormFields($formSelector, $params) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if the array of form parameters (name => value) are not set on the form matched with - * the passed selector. - * - * ``` php - * dontSeeInFormFields('form[name=myform]', [ - * 'input1' => 'non-existent value', - * 'input2' => 'other non-existent value', - * ]); - * ?> - * ``` - * - * To check that an element hasn't been assigned any one of many values, an array can be passed - * as the value: - * - * ``` php - * dontSeeInFormFields('.form-class', [ - * 'fieldName' => [ - * 'This value shouldn\'t be set', - * 'And this value shouldn\'t be set', - * ], - * ]); - * ?> - * ``` - * - * Additionally, checkbox values can be checked with a boolean. - * - * ``` php - * dontSeeInFormFields('#form-id', [ - * 'checkbox1' => true, // fails if checked - * 'checkbox2' => false, // fails if unchecked - * ]); - * ?> - * ``` - * - * @param $formSelector - * @param $params - * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() - */ - public function dontSeeInFormFields($formSelector, $params) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Submits the given form on the page, optionally with the given form values. - * Give the form fields values as an array. - * - * Skipped fields will be filled by their values from the page. - * You don't need to click the 'Submit' button afterwards. - * This command itself triggers the request to form's action. - * - * You can optionally specify what button's value to include - * in the request with the last parameter as an alternative to - * explicitly setting its value in the second parameter, as - * button values are not otherwise included in the request. - * - * Examples: - * - * ``` php - * submitForm('#login', array('login' => 'davert', 'password' => '123456')); - * // or - * $I->submitForm('#login', array('login' => 'davert', 'password' => '123456'), 'submitButtonName'); - * - * ``` - * - * For example, given this sample "Sign Up" form: - * - * ``` html - *
- * Login:
- * Password:
- * Do you agree to out terms?
- * Select pricing plan - * - *
- * ``` - * - * You could write the following to submit it: - * - * ``` php - * submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true)), 'submitButton'); - * - * ``` - * Note that "2" will be the submitted value for the "plan" field, as it is the selected option. - * - * You can also emulate a JavaScript submission by not specifying any buttons in the third parameter to submitForm. - * - * ```php - * submitForm('#userForm', array('user' => array('login' => 'Davert', 'password' => '123456', 'agree' => true))); - * - * ``` - * - * Pair this with seeInFormFields for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * Parameter values can be set to arrays for multiple input fields - * of the same name, or multi-select combo boxes. For checkboxes, - * either the string value can be used, or boolean values which will - * be replaced by the checkbox's value in the DOM. - * - * ``` php - * submitForm('#my-form', [ - * 'field1' => 'value', - * 'checkbox' => [ - * 'value of first checkbox', - * 'value of second checkbox, - * ], - * 'otherCheckboxes' => [ - * true, - * false, - * false - * ], - * 'multiselect' => [ - * 'first option value', - * 'second option value' - * ] - * ]); - * ?> - * ``` - * - * Mixing string and boolean values for a checkbox's value is not - * supported and may produce unexpected results. - * - * @param $selector - * @param $params - * @param $button - * @see \Codeception\Lib\InnerBrowser::submitForm() - */ - public function submitForm($selector, $params, $button = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Fills a text field or textarea with the given string. - * - * ``` php - * fillField("//input[@type='text']", "Hello World!"); - * $I->fillField(['name' => 'email'], 'jon@mail.com'); - * ?> - * ``` - * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::fillField() - */ - public function fillField($field, $value) { - return $this->scenario->runStep(new \Codeception\Step\Action('fillField', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Selects an option in a select tag or in radio button group. - * - * ``` php - * selectOption('form select[name=account]', 'Premium'); - * $I->selectOption('form input[name=payment]', 'Monthly'); - * $I->selectOption('//form/select[@name=account]', 'Monthly'); - * ?> - * ``` - * - * Provide an array for the second argument to select multiple options: - * - * ``` php - * selectOption('Which OS do you use?', array('Windows','Linux')); - * ?> - * ``` - * - * @param $select - * @param $option - * @see \Codeception\Lib\InnerBrowser::selectOption() - */ - public function selectOption($select, $option) { - return $this->scenario->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. - * - * ``` php - * checkOption('#agree'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Lib\InnerBrowser::checkOption() - */ - public function checkOption($option) { - return $this->scenario->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unticks a checkbox. - * - * ``` php - * uncheckOption('#notify'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Lib\InnerBrowser::uncheckOption() - */ - public function uncheckOption($option) { - return $this->scenario->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Attaches a file relative to the Codeception data directory to the given file upload field. - * - * ``` php - * attachFile('input[@type="file"]', 'prices.xls'); - * ?> - * ``` - * - * @param $field - * @param $filename - * @see \Codeception\Lib\InnerBrowser::attachFile() - */ - public function attachFile($field, $filename) { - return $this->scenario->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends a GET ajax request with specified params. - * - * See ->sendAjaxPostRequest for examples. - * - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() - */ - public function sendAjaxGetRequest($uri, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends a POST ajax request with specified params. - * Additional params can be passed as array. - * - * Example: - * - * Imagine that by clicking checkbox you trigger ajax request which updates user settings. - * We emulate that click by running this ajax request manually. - * - * ``` php - * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST - * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET - * - * ``` - * - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() - */ - public function sendAjaxPostRequest($uri, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * If your page triggers an ajax request, you can perform it manually. - * This action sends an ajax request with specified method and params. - * - * Example: - * - * You need to perform an ajax request specifying the HTTP method. - * - * ``` php - * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); - * - * ``` - * - * @param $method - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() - */ - public function sendAjaxRequest($method, $uri, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Finds and returns the text contents of the given element. - * If a fuzzy locator is used, the element is found using CSS, XPath, and by matching the full page source by regular expression. - * - * ``` php - * grabTextFrom('h1'); - * $heading = $I->grabTextFrom('descendant-or-self::h1'); - * $value = $I->grabTextFrom('~ - * ``` - * - * @param $cssOrXPathOrRegex - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabTextFrom() - */ - public function grabTextFrom($cssOrXPathOrRegex) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs the value of the given attribute value from the given element. - * Fails if element is not found. - * - * ``` php - * grabAttributeFrom('#tooltip', 'title'); - * ?> - * ``` - * - * - * @param $cssOrXpath - * @param $attribute - * @internal param $element - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() - */ - public function grabAttributeFrom($cssOrXpath, $attribute) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param $field - * - * @return array|mixed|null|string - * @see \Codeception\Lib\InnerBrowser::grabValueFrom() - */ - public function grabValueFrom($field) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Sets a cookie with the given name and value. - * You can set additional cookie params like `domain`, `path`, `expire`, `secure` in array passed as last argument. - * - * ``` php - * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); - * ?> - * ``` - * - * @param $name - * @param $val - * @param array $params - * @internal param $cookie - * @internal param $value - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::setCookie() - */ - public function setCookie($name, $val, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Grabs a cookie value. - * You can set additional cookie params like `domain`, `path` in array passed as last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabCookie() - */ - public function grabCookie($cookie, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a cookie with the given name is set. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * ``` php - * seeCookie('PHPSESSID'); - * ?> - * ``` - * - * @param $cookie - * @param array $params - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCookie() - */ - public function canSeeCookie($cookie, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a cookie with the given name is set. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * ``` php - * seeCookie('PHPSESSID'); - * ?> - * ``` - * - * @param $cookie - * @param array $params - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeCookie() - */ - public function seeCookie($cookie, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there isn't a cookie with the given name. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() - */ - public function cantSeeCookie($cookie, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there isn't a cookie with the given name. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() - */ - public function dontSeeCookie($cookie, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Unsets cookie with the given name. - * You can set additional cookie params like `domain`, `path` in array passed as last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Lib\InnerBrowser::resetCookie() - */ - public function resetCookie($name, $params = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page and is visible. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @return - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeElement() - */ - public function canSeeElement($selector, $attributes = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page and is visible. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @return - * @see \Codeception\Lib\InnerBrowser::seeElement() - */ - public function seeElement($selector, $attributes = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element is invisible or not present on the page. - * You can also specify expected attributes of this element. - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeElement() - */ - public function cantSeeElement($selector, $attributes = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element is invisible or not present on the page. - * You can also specify expected attributes of this element. - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @see \Codeception\Lib\InnerBrowser::dontSeeElement() - */ - public function dontSeeElement($selector, $attributes = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there are a certain number of elements matched by the given locator on the page. - * - * ``` php - * seeNumberOfElements('tr', 10); - * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements - * ?> - * ``` - * @param $selector - * @param mixed $expected: - * - string: strict number - * - array: range of numbers [0,10] - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() - */ - public function canSeeNumberOfElements($selector, $expected) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there are a certain number of elements matched by the given locator on the page. - * - * ``` php - * seeNumberOfElements('tr', 10); - * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements - * ?> - * ``` - * @param $selector - * @param mixed $expected: - * - string: strict number - * - array: range of numbers [0,10] - * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() - */ - public function seeNumberOfElements($selector, $expected) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is selected. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() - */ - public function canSeeOptionIsSelected($selector, $optionText) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is selected. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() - */ - public function seeOptionIsSelected($selector, $optionText) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is not selected. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() - */ - public function cantSeeOptionIsSelected($selector, $optionText) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is not selected. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() - */ - public function dontSeeOptionIsSelected($selector, $optionText) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that current page has 404 response status code. - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seePageNotFound() - */ - public function canSeePageNotFound() { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that current page has 404 response status code. - * @see \Codeception\Lib\InnerBrowser::seePageNotFound() - */ - public function seePageNotFound() { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that response code is equal to value provided. - * - * @param $code - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() - */ - public function canSeeResponseCodeIs($code) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that response code is equal to value provided. - * - * @param $code - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() - */ - public function seeResponseCodeIs($code) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title contains the given string. - * - * ``` php - * seeInTitle('Blog - Post #1'); - * ?> - * ``` - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInTitle() - */ - public function canSeeInTitle($title) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title contains the given string. - * - * ``` php - * seeInTitle('Blog - Post #1'); - * ?> - * ``` - * - * @param $title - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::seeInTitle() - */ - public function seeInTitle($title) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title does not contain the given string. - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() - */ - public function cantSeeInTitle($title) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title does not contain the given string. - * - * @param $title - * - * @return mixed - * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() - */ - public function dontSeeInTitle($title) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * @see \Codeception\Module\DbDropTablesHelper::cleanup() - */ - public function cleanup() { - return $this->scenario->runStep(new \Codeception\Step\Action('cleanup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Enters a directory In local filesystem. - * Project root directory is used by default - * - * @param $path - * @see \Codeception\Module\Filesystem::amInPath() - */ - public function amInPath($path) { - return $this->scenario->runStep(new \Codeception\Step\Condition('amInPath', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opens a file and stores it's content. - * - * Usage: - * - * ``` php - * openFile('composer.json'); - * $I->seeInThisFile('codeception/codeception'); - * ?> - * ``` - * - * @param $filename - * @see \Codeception\Module\Filesystem::openFile() - */ - public function openFile($filename) { - return $this->scenario->runStep(new \Codeception\Step\Action('openFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Deletes a file - * - * ``` php - * deleteFile('composer.lock'); - * ?> - * ``` - * - * @param $filename - * @see \Codeception\Module\Filesystem::deleteFile() - */ - public function deleteFile($filename) { - return $this->scenario->runStep(new \Codeception\Step\Action('deleteFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Deletes directory with all subdirectories - * - * ``` php - * deleteDir('vendor'); - * ?> - * ``` - * - * @param $dirname - * @see \Codeception\Module\Filesystem::deleteDir() - */ - public function deleteDir($dirname) { - return $this->scenario->runStep(new \Codeception\Step\Action('deleteDir', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Copies directory with all contents - * - * ``` php - * copyDir('vendor','old_vendor'); - * ?> - * ``` - * - * @param $src - * @param $dst - * @see \Codeception\Module\Filesystem::copyDir() - */ - public function copyDir($src, $dst) { - return $this->scenario->runStep(new \Codeception\Step\Action('copyDir', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks If opened file has `text` in it. - * - * Usage: - * - * ``` php - * openFile('composer.json'); - * $I->seeInThisFile('codeception/codeception'); - * ?> - * ``` - * - * @param $text - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\Filesystem::seeInThisFile() - */ - public function canSeeInThisFile($text) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInThisFile', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks If opened file has `text` in it. - * - * Usage: - * - * ``` php - * openFile('composer.json'); - * $I->seeInThisFile('codeception/codeception'); - * ?> - * ``` - * - * @param $text - * @see \Codeception\Module\Filesystem::seeInThisFile() - */ - public function seeInThisFile($text) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInThisFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks the strict matching of file contents. - * Unlike `seeInThisFile` will fail if file has something more than expected lines. - * Better to use with HEREDOC strings. - * Matching is done after removing "\r" chars from file content. - * - * ``` php - * openFile('process.pid'); - * $I->seeFileContentsEqual('3192'); - * ?> - * ``` - * - * @param $text - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\Filesystem::seeFileContentsEqual() - */ - public function canSeeFileContentsEqual($text) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeFileContentsEqual', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks the strict matching of file contents. - * Unlike `seeInThisFile` will fail if file has something more than expected lines. - * Better to use with HEREDOC strings. - * Matching is done after removing "\r" chars from file content. - * - * ``` php - * openFile('process.pid'); - * $I->seeFileContentsEqual('3192'); - * ?> - * ``` - * - * @param $text - * @see \Codeception\Module\Filesystem::seeFileContentsEqual() - */ - public function seeFileContentsEqual($text) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeFileContentsEqual', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks If opened file doesn't contain `text` in it - * - * ``` php - * openFile('composer.json'); - * $I->dontSeeInThisFile('codeception/codeception'); - * ?> - * ``` - * - * @param $text - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\Filesystem::dontSeeInThisFile() - */ - public function cantSeeInThisFile($text) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInThisFile', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks If opened file doesn't contain `text` in it - * - * ``` php - * openFile('composer.json'); - * $I->dontSeeInThisFile('codeception/codeception'); - * ?> - * ``` - * - * @param $text - * @see \Codeception\Module\Filesystem::dontSeeInThisFile() - */ - public function dontSeeInThisFile($text) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInThisFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Deletes a file - * @see \Codeception\Module\Filesystem::deleteThisFile() - */ - public function deleteThisFile() { - return $this->scenario->runStep(new \Codeception\Step\Action('deleteThisFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if file exists in path. - * Opens a file when it's exists - * - * ``` php - * seeFileFound('UserModel.php','app/models'); - * ?> - * ``` - * - * @param $filename - * @param string $path - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\Filesystem::seeFileFound() - */ - public function canSeeFileFound($filename, $path = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeFileFound', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if file exists in path. - * Opens a file when it's exists - * - * ``` php - * seeFileFound('UserModel.php','app/models'); - * ?> - * ``` - * - * @param $filename - * @param string $path - * @see \Codeception\Module\Filesystem::seeFileFound() - */ - public function seeFileFound($filename, $path = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('seeFileFound', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if file does not exists in path - * - * @param $filename - * @param string $path - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\Filesystem::dontSeeFileFound() - */ - public function cantSeeFileFound($filename, $path = null) { - return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeFileFound', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks if file does not exists in path - * - * @param $filename - * @param string $path - * @see \Codeception\Module\Filesystem::dontSeeFileFound() - */ - public function dontSeeFileFound($filename, $path = null) { - return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeFileFound', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Erases directory contents - * - * ``` php - * cleanDir('logs'); - * ?> - * ``` - * - * @param $dirname - * @see \Codeception\Module\Filesystem::cleanDir() - */ - public function cleanDir($dirname) { - return $this->scenario->runStep(new \Codeception\Step\Action('cleanDir', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Saves contents to file - * - * @param $filename - * @param $contents - * @see \Codeception\Module\Filesystem::writeToFile() - */ - public function writeToFile($filename, $contents) { - return $this->scenario->runStep(new \Codeception\Step\Action('writeToFile', func_get_args())); - } -} 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/FuncIncTest.php b/tests/Unit/FuncIncTest.php similarity index 100% rename from tests/unit/FuncIncTest.php rename to tests/Unit/FuncIncTest.php 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/context/ContextTest.php similarity index 100% rename from tests/unit/classes/context/ContextTest.php rename to tests/Unit/classes/context/ContextTest.php diff --git a/tests/unit/classes/file/FileHandlerTest.php b/tests/Unit/classes/file/FileHandlerTest.php similarity index 100% rename from tests/unit/classes/file/FileHandlerTest.php rename to tests/Unit/classes/file/FileHandlerTest.php diff --git a/tests/unit/classes/frontendfile/FrontEndFileHandlerTest.php b/tests/Unit/classes/frontendfile/FrontEndFileHandlerTest.php similarity index 100% rename from tests/unit/classes/frontendfile/FrontEndFileHandlerTest.php rename to tests/Unit/classes/frontendfile/FrontEndFileHandlerTest.php diff --git a/tests/unit/classes/security/SecurityTest.php b/tests/Unit/classes/security/SecurityTest.php similarity index 100% rename from tests/unit/classes/security/SecurityTest.php rename to tests/Unit/classes/security/SecurityTest.php diff --git a/tests/unit/classes/template/TemplateHandlerTest.php b/tests/Unit/classes/template/TemplateHandlerTest.php similarity index 93% rename from tests/unit/classes/template/TemplateHandlerTest.php rename to tests/Unit/classes/template/TemplateHandlerTest.php index 4ec211c6c..e3168ad2f 100644 --- a/tests/unit/classes/template/TemplateHandlerTest.php +++ b/tests/Unit/classes/template/TemplateHandlerTest.php @@ -1,7 +1,7 @@
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,11 +269,11 @@ 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', 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/ValidatorTest.php b/tests/Unit/classes/validator/ValidatorTest.php similarity index 100% rename from tests/unit/classes/validator/ValidatorTest.php rename to tests/Unit/classes/validator/ValidatorTest.php 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/UnitTester.php b/tests/unit/UnitTester.php deleted file mode 100644 index 65d410d75..000000000 --- a/tests/unit/UnitTester.php +++ /dev/null @@ -1,300 +0,0 @@ -scenario->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that two variables are not equal - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNotEquals() - */ - public function assertNotEquals($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that two variables are same - * - * @param $expected - * @param $actual - * @param string $message - * - * @return mixed - * @see \Codeception\Module\Asserts::assertSame() - */ - public function assertSame($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertSame', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that two variables are not same - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNotSame() - */ - public function assertNotSame($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that actual is greater than expected - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertGreaterThan() - */ - public function assertGreaterThan($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @deprecated - * @see \Codeception\Module\Asserts::assertGreaterThen() - */ - public function assertGreaterThen($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that actual is greater or equal than expected - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertGreaterThanOrEqual() - */ - public function assertGreaterThanOrEqual($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @deprecated - * @see \Codeception\Module\Asserts::assertGreaterThenOrEqual() - */ - public function assertGreaterThenOrEqual($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that actual is less than expected - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertLessThan() - */ - public function assertLessThan($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that actual is less or equal than expected - * - * @param $expected - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertLessThanOrEqual() - */ - public function assertLessThanOrEqual($expected, $actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that haystack contains needle - * - * @param $needle - * @param $haystack - * @param string $message - * @see \Codeception\Module\Asserts::assertContains() - */ - public function assertContains($needle, $haystack, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that haystack doesn't contain needle. - * - * @param $needle - * @param $haystack - * @param string $message - * @see \Codeception\Module\Asserts::assertNotContains() - */ - public function assertNotContains($needle, $haystack, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that variable is empty. - * - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertEmpty() - */ - public function assertEmpty($actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that variable is not empty. - * - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNotEmpty() - */ - public function assertNotEmpty($actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that variable is NULL - * - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNull() - */ - public function assertNull($actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that variable is not NULL - * - * @param $actual - * @param string $message - * @see \Codeception\Module\Asserts::assertNotNull() - */ - public function assertNotNull($actual, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that condition is positive. - * - * @param $condition - * @param string $message - * @see \Codeception\Module\Asserts::assertTrue() - */ - public function assertTrue($condition, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertTrue', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that condition is negative. - * - * @param $condition - * @param string $message - * @see \Codeception\Module\Asserts::assertFalse() - */ - public function assertFalse($condition, $message = null) { - return $this->scenario->runStep(new \Codeception\Step\Action('assertFalse', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Fails the test with message. - * - * @param $message - * @see \Codeception\Module\Asserts::fail() - */ - public function fail($message) { - return $this->scenario->runStep(new \Codeception\Step\Action('fail', func_get_args())); - } -} diff --git a/tools/README.md b/tools/README.md deleted file mode 100644 index 7ad481795..000000000 --- a/tools/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# Tools - -## Build -XE패키징을 위해 grunt.js를 이용한 Task로 작성되어 있으며 *nix 환경에서 Node를 구동할 수 있어야 한다. - -### 의존 패키지 설치 (Mac) - -### 1. brew -http://brew.sh 페이지의 'Install Homebrew'를 참고하여 설치 - -### 2. node.js -> brew install node - -### 3. grunt-cli -> npm install -g grunt-cli - -## node 모듈 설치 -grunt task 수행에 필요한 node 모듈의 설치를 먼저 수행한다. - -XE 패키지의 루트… index.php 또는 Gruntfile.js 파일이 있는 곳에서 다음 명령으로 의존 모듈이 자동 설치된다. - -> npm install - -## Build -build 수행 전 Minified 파일이 갱신되도록 패키징 하려는 브랜치에서 아래 Task 중 `grunt minify`를 반드시 먼저 수행하도록 한다. - -build 명령으로 zip, tgz 포맷으로 패키징을 수행하며 지정한 대상의 변경된 파일만을 묶은 changed 파일을 함께 생성한다. - -> grunt build`:from`:`to` - -`from`, `to`에는 commit hash 또는 tag, branch를 지정할 수 있다. 패키지는 `to`에 지정한 대상을 기준으로하며 `from`과 `to`사이에 변경된 파일들 changed 파일을 별도로 생성한다. - -> grunt build:`old_tag`:`current_tag` - -이와 같이 지정하면 `old_tag`로부터 `current_tag` 사이의 변경된 파일만을 묶은 `xe.current_tag.changed.*` 파일과 `xe.current_tag.*`파일을 생성한다. - -`from`을 생략하여 `build:master`(master는 branch이다)와 같이 지정하면 `master`의 최신 상태로 빌드하며 changed 파일을 생성하지 않는다. - -### Build 수행 시 포함하는 패키지 -Build 수행 시 일부 확장 기능을 가져와 함게 패키징한다. 지정한 각 저장소의 master 브랜치로부터 코드를 가져오므로 **Build 수행 전에 각 저장소의 master 상태를 확인하도록 한다.** - -* board 모듈 - * https://github.com/xpressengine/xe-module-board -* krzip 모듈 - * https://github.com/xpressengine/xe-module-krzip -* syndication 모듈 - * https://github.com/xpressengine/xe-module-syndication - -## Task -.js, .css, .php 파일들에 대해 문법 검사 및 권장 코드를 확인할 수 있으며 minify 등의 작업을 수행할 수 있다. - -### Lint -.js, .css, .php 파일에 대해 문법 검사 등을 수행한다. -> grunt lint - -다음과 같이 선택적으로 수행할 수 있다. - -#### JS Lint (jshint) -`lint`가 아닌 `hint`임에 주의. -> grunt jshint - -#### CSS Lint -> grunt csslint - -### Minify -.js, .css 파일의 공백을 지우는 등 minify 동작을 수행할 수 있으며 대상은 Gruntfile.js 파일에 정의되어 있다. - - > grunt minify diff --git a/tools/minify/cssmin/CSSmin.php b/tools/minify/cssmin/CSSmin.php deleted file mode 100644 index a32bb7832..000000000 --- a/tools/minify/cssmin/CSSmin.php +++ /dev/null @@ -1,729 +0,0 @@ - */ - -/*! - * cssmin.php rev 91c5ea5 - * Author: Tubal Martin - http://blog.margenn.com/ - * Repo: https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port - * - * This is a PHP port of the Javascript port of the CSS minification tool - * distributed with YUICompressor, itself a port of the cssmin utility by - * Isaac Schlueter - http://foohack.com/ - * Permission is hereby granted to use the PHP version under the same - * conditions as the YUICompressor. - */ - -/*! - * YUI Compressor - * http://developer.yahoo.com/yui/compressor/ - * Author: Julien Lecomte - http://www.julienlecomte.net/ - * Copyright (c) 2011 Yahoo! Inc. All rights reserved. - * The copyrights embodied in the content of this file are licensed - * by Yahoo! Inc. under the BSD (revised) open source license. - */ - -class CSSmin -{ - const NL = '___YUICSSMIN_PRESERVED_NL___'; - const TOKEN = '___YUICSSMIN_PRESERVED_TOKEN_'; - const COMMENT = '___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_'; - const CLASSCOLON = '___YUICSSMIN_PSEUDOCLASSCOLON___'; - - private $comments; - private $preserved_tokens; - private $memory_limit; - private $max_execution_time; - private $pcre_backtrack_limit; - private $pcre_recursion_limit; - private $raise_php_limits; - - /** - * @param bool|int $raise_php_limits - * If true, PHP settings will be raised if needed - */ - public function __construct($raise_php_limits = TRUE) - { - // Set suggested PHP limits - $this->memory_limit = 128 * 1048576; // 128MB in bytes - $this->max_execution_time = 60; // 1 min - $this->pcre_backtrack_limit = 1000 * 1000; - $this->pcre_recursion_limit = 500 * 1000; - - $this->raise_php_limits = (bool) $raise_php_limits; - } - - /** - * Minify a string of CSS - * @param string $css - * @param int|bool $linebreak_pos - * @return string - */ - public function run($css = '', $linebreak_pos = FALSE) - { - if (empty($css)) { - return ''; - } - - if ($this->raise_php_limits) { - $this->do_raise_php_limits(); - } - - $this->comments = array(); - $this->preserved_tokens = array(); - - $start_index = 0; - $length = strlen($css); - - $css = $this->extract_data_urls($css); - - // collect all comment blocks... - while (($start_index = $this->index_of($css, '/*', $start_index)) >= 0) { - $end_index = $this->index_of($css, '*/', $start_index + 2); - if ($end_index < 0) { - $end_index = $length; - } - $comment_found = $this->str_slice($css, $start_index + 2, $end_index); - $this->comments[] = $comment_found; - $comment_preserve_string = self::COMMENT . (count($this->comments) - 1) . '___'; - $css = $this->str_slice($css, 0, $start_index + 2) . $comment_preserve_string . $this->str_slice($css, $end_index); - // Set correct start_index: Fixes issue #2528130 - $start_index = $end_index + 2 + strlen($comment_preserve_string) - strlen($comment_found); - } - - // preserve strings so their content doesn't get accidentally minified - $css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|'."(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css); - - // Let's divide css code in chunks of 25.000 chars aprox. - // Reason: PHP's PCRE functions like preg_replace have a "backtrack limit" - // of 100.000 chars by default (php < 5.3.7) so if we're dealing with really - // long strings and a (sub)pattern matches a number of chars greater than - // the backtrack limit number (i.e. /(.*)/s) PCRE functions may fail silently - // returning NULL and $css would be empty. - $charset = ''; - $charset_regexp = '/@charset [^;]+;/i'; - $css_chunks = array(); - $css_chunk_length = 25000; // aprox size, not exact - $start_index = 0; - $i = $css_chunk_length; // save initial iterations - $l = strlen($css); - - - // if the number of characters is 25000 or less, do not chunk - if ($l <= $css_chunk_length) { - $css_chunks[] = $css; - } else { - // chunk css code securely - while ($i < $l) { - $i += 50; // save iterations. 500 checks for a closing curly brace } - if ($l - $start_index <= $css_chunk_length || $i >= $l) { - $css_chunks[] = $this->str_slice($css, $start_index); - break; - } - if ($css[$i - 1] === '}' && $i - $start_index > $css_chunk_length) { - // If there are two ending curly braces }} separated or not by spaces, - // join them in the same chunk (i.e. @media blocks) - $next_chunk = substr($css, $i); - if (preg_match('/^\s*\}/', $next_chunk)) { - $i = $i + $this->index_of($next_chunk, '}') + 1; - } - - $css_chunks[] = $this->str_slice($css, $start_index, $i); - $start_index = $i; - } -} -} - -// Minify each chunk -for ($i = 0, $n = count($css_chunks); $i < $n; $i++) { - $css_chunks[$i] = $this->minify($css_chunks[$i], $linebreak_pos); - // Keep the first @charset at-rule found - if (empty($charset) && preg_match($charset_regexp, $css_chunks[$i], $matches)) { - $charset = $matches[0]; - } - // Delete all @charset at-rules - $css_chunks[$i] = preg_replace($charset_regexp, '', $css_chunks[$i]); -} - -// Update the first chunk and push the charset to the top of the file. -$css_chunks[0] = $charset . $css_chunks[0]; - -return implode('', $css_chunks); -} - -/** - * Sets the memory limit for this script - * @param int|string $limit - */ -public function set_memory_limit($limit) -{ - $this->memory_limit = $this->normalize_int($limit); -} - -/** - * Sets the maximum execution time for this script - * @param int|string $seconds - */ -public function set_max_execution_time($seconds) -{ - $this->max_execution_time = (int) $seconds; -} - -/** - * Sets the PCRE backtrack limit for this script - * @param int $limit - */ -public function set_pcre_backtrack_limit($limit) -{ - $this->pcre_backtrack_limit = (int) $limit; -} - -/** - * Sets the PCRE recursion limit for this script - * @param int $limit - */ -public function set_pcre_recursion_limit($limit) -{ - $this->pcre_recursion_limit = (int) $limit; -} - -/** - * Try to configure PHP to use at least the suggested minimum settings - */ -private function do_raise_php_limits() -{ - $php_limits = array( - 'memory_limit' => $this->memory_limit, - 'max_execution_time' => $this->max_execution_time, - 'pcre.backtrack_limit' => $this->pcre_backtrack_limit, - 'pcre.recursion_limit' => $this->pcre_recursion_limit - ); - - // If current settings are higher respect them. - foreach ($php_limits as $name => $suggested) { - $current = $this->normalize_int(ini_get($name)); - // memory_limit exception: allow -1 for "no memory limit". - if ($current > -1 && ($suggested == -1 || $current < $suggested)) { - ini_set($name, $suggested); - } - } -} - -/** - * Does bulk of the minification - * @param string $css - * @param int|bool $linebreak_pos - * @return string - */ -private function minify($css, $linebreak_pos) -{ - // strings are safe, now wrestle the comments - for ($i = 0, $max = count($this->comments); $i < $max; $i++) { - - $token = $this->comments[$i]; - $placeholder = '/' . self::COMMENT . $i . '___/'; - - // ! in the first position of the comment means preserve - // so push to the preserved tokens keeping the ! - if (substr($token, 0, 1) === '!') { - $this->preserved_tokens[] = $token; - $token_tring = self::TOKEN . (count($this->preserved_tokens) - 1) . '___'; - $css = preg_replace($placeholder, $token_tring, $css, 1); - // Preserve new lines for /*! important comments - $css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'. $token_tring .')/S', self::NL.'$1', $css); - $css = preg_replace('/('. $token_tring .'\*\/)\s*[\n\r\f]+\s*/S', '$1'.self::NL, $css); - continue; - } - - // \ in the last position looks like hack for Mac/IE5 - // shorten that to /*\*/ and the next one to /**/ - if (substr($token, (strlen($token) - 1), 1) === '\\') { - $this->preserved_tokens[] = '\\'; - $css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); - $i = $i + 1; // attn: advancing the loop - $this->preserved_tokens[] = ''; - $css = preg_replace('/' . self::COMMENT . $i . '___/', self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); - continue; - } - - // keep empty comments after child selectors (IE7 hack) - // e.g. html >/**/ body - if (strlen($token) === 0) { - $start_index = $this->index_of($css, $this->str_slice($placeholder, 1, -1)); - if ($start_index > 2) { - if (substr($css, $start_index - 3, 1) === '>') { - $this->preserved_tokens[] = ''; - $css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); - } - } - } - - // in all other cases kill the comment - $css = preg_replace('/\/\*' . $this->str_slice($placeholder, 1, -1) . '\*\//', '', $css, 1); - } - - - // Normalize all whitespace strings to single spaces. Easier to work with that way. - $css = preg_replace('/\s+/', ' ', $css); - - // Shorten & preserve calculations calc(...) since spaces are important - $css = preg_replace_callback('/calc(\((?:[^\(\)]+|(?1))*\))/i', array($this, 'replace_calc'), $css); - - // Replace positive sign from numbers preceded by : or a white-space before the leading space is removed - // +1.2em to 1.2em, +.8px to .8px, +2% to 2% - $css = preg_replace('/((? -9.0 to -9 - $css = preg_replace('/((?\+\(\)\]\~\=,])/', '$1', $css); - $css = preg_replace('/' . self::CLASSCOLON . '/', ':', $css); - - // retain space for special IE6 cases - $css = preg_replace('/\:first\-(line|letter)(\{|,)/i', ':first-$1 $2', $css); - - // no space after the end of a preserved comment - $css = preg_replace('/\*\/ /', '*/', $css); - - // Put the space back in some cases, to support stuff like - // @media screen and (-webkit-min-device-pixel-ratio:0){ - $css = preg_replace('/\band\(/i', 'and (', $css); - - // Remove the spaces after the things that should not have spaces after them. - $css = preg_replace('/([\!\{\}\:;\>\+\(\[\~\=,])\s+/S', '$1', $css); - - // remove unnecessary semicolons - $css = preg_replace('/;+\}/', '}', $css); - - // Fix for issue: #2528146 - // Restore semicolon if the last property is prefixed with a `*` (lte IE7 hack) - // to avoid issues on Symbian S60 3.x browsers. - $css = preg_replace('/(\*[a-z0-9\-]+\s*\:[^;\}]+)(\})/', '$1;$2', $css); - - // Replace 0 length units 0(px,em,%) with 0. - $css = preg_replace('/((?compress_hex_colors($css); - - // border: none to border:0, outline: none to outline:0 - $css = preg_replace('/(border\-?(?:top|right|bottom|left|)|outline)\:none(;|\})/ieS', "strtolower('$1:0$2')", $css); - - // shorter opacity IE filter - $css = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $css); - - // Remove empty rules. - $css = preg_replace('/[^\};\{\/]+\{\}/S', '', $css); - - // Some source control tools don't like it when files containing lines longer - // than, say 8000 characters, are checked in. The linebreak option is used in - // that case to split long lines after a specific column. - if ($linebreak_pos !== FALSE && (int) $linebreak_pos >= 0) { - $linebreak_pos = (int) $linebreak_pos; - $start_index = $i = 0; - while ($i < strlen($css)) { - $i++; - if ($css[$i - 1] === '}' && $i - $start_index > $linebreak_pos) { - $css = $this->str_slice($css, 0, $i) . "\n" . $this->str_slice($css, $i); - $start_index = $i; - } - } - } - - // Replace multiple semi-colons in a row by a single one - // See SF bug #1980989 - $css = preg_replace('/;;+/', ';', $css); - - // Restore new lines for /*! important comments - $css = preg_replace('/'. self::NL .'/', "\n", $css); - - // restore preserved comments and strings - for ($i = 0, $max = count($this->preserved_tokens); $i < $max; $i++) { - $css = preg_replace('/' . self::TOKEN . $i . '___/', $this->preserved_tokens[$i], $css, 1); - } - - // Trim the final string (for any leading or trailing white spaces) - return trim($css); -} - -/** - * Utility method to replace all data urls with tokens before we start - * compressing, to avoid performance issues running some of the subsequent - * regexes against large strings chunks. - * - * @param string $css - * @return string - */ -private function extract_data_urls($css) -{ - // Leave data urls alone to increase parse performance. - $max_index = strlen($css) - 1; - $append_index = $index = $last_index = $offset = 0; - $sb = array(); - $pattern = '/url\(\s*(["\']?)data\:/i'; - - // Since we need to account for non-base64 data urls, we need to handle - // ' and ) being part of the data string. Hence switching to indexOf, - // to determine whether or not we have matching string terminators and - // handling sb appends directly, instead of using matcher.append* methods. - - while (preg_match($pattern, $css, $m, 0, $offset)) { - $index = $this->index_of($css, $m[0], $offset); - $last_index = $index + strlen($m[0]); - $start_index = $index + 4; // "url(".length() - $end_index = $last_index - 1; - $terminator = $m[1]; // ', " or empty (not quoted) - $found_terminator = FALSE; - - if (strlen($terminator) === 0) { - $terminator = ')'; - } - - while ($found_terminator === FALSE && $end_index+1 <= $max_index) { - $end_index = $this->index_of($css, $terminator, $end_index + 1); - - // endIndex == 0 doesn't really apply here - if ($end_index > 0 && substr($css, $end_index - 1, 1) !== '\\') { - $found_terminator = TRUE; - if (')' != $terminator) { - $end_index = $this->index_of($css, ')', $end_index); - } - } - } - - // Enough searching, start moving stuff over to the buffer - $sb[] = $this->substring($css, $append_index, $index); - - if ($found_terminator) { - $token = $this->substring($css, $start_index, $end_index); - $token = preg_replace('/\s+/', '', $token); - $this->preserved_tokens[] = $token; - - $preserver = 'url(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___)'; - $sb[] = $preserver; - - $append_index = $end_index + 1; - } else { - // No end terminator found, re-add the whole match. Should we throw/warn here? - $sb[] = $this->substring($css, $index, $last_index); - $append_index = $last_index; - } - - $offset = $last_index; - } - - $sb[] = $this->substring($css, $append_index); - - return implode('', $sb); -} - -/** - * Utility method to compress hex color values of the form #AABBCC to #ABC or short color name. - * - * DOES NOT compress CSS ID selectors which match the above pattern (which would break things). - * e.g. #AddressForm { ... } - * - * DOES NOT compress IE filters, which have hex color values (which would break things). - * e.g. filter: chroma(color="#FFFFFF"); - * - * DOES NOT compress invalid hex values. - * e.g. background-color: #aabbccdd - * - * @param string $css - * @return string - */ -private function compress_hex_colors($css) -{ - // Look for hex colors inside { ... } (to avoid IDs) and which don't have a =, or a " in front of them (to avoid filters) - $pattern = '/(\=\s*?["\']?)?#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])(\}|[^0-9a-f{][^{]*?\})/iS'; - $_index = $index = $last_index = $offset = 0; - $sb = array(); - // See: http://ajaxmin.codeplex.com/wikipage?title=CSS%20Colors - $short_safe = array( - '#808080' => 'gray', - '#008000' => 'green', - '#800000' => 'maroon', - '#000080' => 'navy', - '#808000' => 'olive', - '#800080' => 'purple', - '#c0c0c0' => 'silver', - '#008080' => 'teal', - '#f00' => 'red' - ); - - while (preg_match($pattern, $css, $m, 0, $offset)) { - $index = $this->index_of($css, $m[0], $offset); - $last_index = $index + strlen($m[0]); - $is_filter = (bool) $m[1]; - - $sb[] = $this->substring($css, $_index, $index); - - if ($is_filter) { - // Restore, maintain case, otherwise filter will break - $sb[] = $m[1] . '#' . $m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7]; - } else { - if (strtolower($m[2]) == strtolower($m[3]) && - strtolower($m[4]) == strtolower($m[5]) && - strtolower($m[6]) == strtolower($m[7])) { - // Compress. - $hex = '#' . strtolower($m[3] . $m[5] . $m[7]); - } else { - // Non compressible color, restore but lower case. - $hex = '#' . strtolower($m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7]); - } - // replace Hex colors to short safe color names - $sb[] = array_key_exists($hex, $short_safe) ? $short_safe[$hex] : $hex; - } - - $_index = $offset = $last_index - strlen($m[8]); - } - - $sb[] = $this->substring($css, $_index); - - return implode('', $sb); -} - -/* CALLBACKS - * --------------------------------------------------------------------------------------------- - */ - -private function replace_string($matches) -{ - $match = $matches[0]; - $quote = substr($match, 0, 1); - // Must use addcslashes in PHP to avoid parsing of backslashes - $match = addcslashes($this->str_slice($match, 1, -1), '\\'); - - // maybe the string contains a comment-like substring? - // one, maybe more? put'em back then - if (($pos = $this->index_of($match, self::COMMENT)) >= 0) { - for ($i = 0, $max = count($this->comments); $i < $max; $i++) { - $match = preg_replace('/' . self::COMMENT . $i . '___/', $this->comments[$i], $match, 1); - } - } - - // minify alpha opacity in filter strings - $match = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $match); - - $this->preserved_tokens[] = $match; - return $quote . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . $quote; - } - - private function replace_colon($matches) - { - return preg_replace('/\:/', self::CLASSCOLON, $matches[0]); - } - - private function replace_calc($matches) - { - $this->preserved_tokens[] = preg_replace('/\s?([\*\/\(\),])\s?/', '$1', $matches[0]); - return self::TOKEN . (count($this->preserved_tokens) - 1) . '___'; - } - - private function rgb_to_hex($matches) - { - // Support for percentage values rgb(100%, 0%, 45%); - if ($this->index_of($matches[1], '%') >= 0){ - $rgbcolors = explode(',', str_replace('%', '', $matches[1])); - for ($i = 0; $i < count($rgbcolors); $i++) { - $rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55); - } - } else { - $rgbcolors = explode(',', $matches[1]); - } - - // Values outside the sRGB color space should be clipped (0-255) - for ($i = 0; $i < count($rgbcolors); $i++) { - $rgbcolors[$i] = $this->clamp_number(intval($rgbcolors[$i], 10), 0, 255); - $rgbcolors[$i] = sprintf("%02x", $rgbcolors[$i]); - } - - // Fix for issue #2528093 - if (!preg_match('/[\s\,\);\}]/', $matches[2])){ - $matches[2] = ' ' . $matches[2]; - } - - return '#' . implode('', $rgbcolors) . $matches[2]; - } - -private function hsl_to_hex($matches) -{ - $values = explode(',', str_replace('%', '', $matches[1])); - $h = floatval($values[0]); - $s = floatval($values[1]); - $l = floatval($values[2]); - - // Wrap and clamp, then fraction! - $h = ((($h % 360) + 360) % 360) / 360; - $s = $this->clamp_number($s, 0, 100) / 100; - $l = $this->clamp_number($l, 0, 100) / 100; - - if ($s == 0) { - $r = $g = $b = $this->round_number(255 * $l); - } else { - $v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l); - $v1 = (2 * $l) - $v2; - $r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1/3))); - $g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h)); - $b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1/3))); - } - - return $this->rgb_to_hex(array('', $r.','.$g.','.$b, $matches[2])); -} - -/* HELPERS - * --------------------------------------------------------------------------------------------- - */ - -private function hue_to_rgb($v1, $v2, $vh) -{ - $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); - if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh; - if ($vh * 2 < 1) return $v2; - if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; - return $v1; -} - -private function round_number($n) -{ - return intval(floor(floatval($n) + 0.5), 10); -} - -private function clamp_number($n, $min, $max) -{ - return min(max($n, $min), $max); -} - -/** - * PHP port of Javascript's "indexOf" function for strings only - * Author: Tubal Martin http://blog.margenn.com - * - * @param string $haystack - * @param string $needle - * @param int $offset index (optional) - * @return int - */ -private function index_of($haystack, $needle, $offset = 0) -{ - $index = strpos($haystack, $needle, $offset); - - return ($index !== FALSE) ? $index : -1; -} - -/** - * PHP port of Javascript's "substring" function - * Author: Tubal Martin http://blog.margenn.com - * Tests: http://margenn.com/tubal/substring/ - * - * @param string $str - * @param int $from index - * @param int|bool $to index (optional) - * @return string - */ -private function substring($str, $from = 0, $to = FALSE) -{ - if ($to !== FALSE) { - if ($from == $to || ($from <= 0 && $to < 0)) { - return ''; - } - - if ($from > $to) { - $from_copy = $from; - $from = $to; - $to = $from_copy; - } - } - - if ($from < 0) { - $from = 0; - } - - $substring = ($to === FALSE) ? substr($str, $from) : substr($str, $from, $to - $from); - return ($substring === FALSE) ? '' : $substring; -} - -/** - * PHP port of Javascript's "slice" function for strings only - * Author: Tubal Martin http://blog.margenn.com - * Tests: http://margenn.com/tubal/str_slice/ - * - * @param string $str - * @param int $start index - * @param int|bool $end index (optional) - * @return string - */ -private function str_slice($str, $start = 0, $end = FALSE) -{ - if ($end !== FALSE && ($start < 0 || $end <= 0)) { - $max = strlen($str); - - if ($start < 0) { - if (($start = $max + $start) < 0) { - return ''; - } - } - - if ($end < 0) { - if (($end = $max + $end) < 0) { - return ''; - } - } - - if ($end <= $start) { - return ''; - } - } - - $slice = ($end === FALSE) ? substr($str, $start) : substr($str, $start, $end - $start); - return ($slice === FALSE) ? '' : $slice; -} - -/** - * Convert strings like "64M" or "30" to int values - * @param mixed $size - * @return int - */ -private function normalize_int($size) -{ - if (is_string($size)) { - switch (substr($size, -1)) { - case 'M': case 'm': return $size * 1048576; - case 'K': case 'k': return $size * 1024; - case 'G': case 'g': return $size * 1073741824; - } - } - - return (int) $size; -} -} diff --git a/tools/minify/jsminplus/changelog.txt b/tools/minify/jsminplus/changelog.txt deleted file mode 100644 index 3e76d9770..000000000 --- a/tools/minify/jsminplus/changelog.txt +++ /dev/null @@ -1,62 +0,0 @@ -================================================================================ -JSMin+ -================================================================================ -A javascript minification tool written in PHP -by Tweakers.net / Tino Zijdel - -Weblog: http://crisp.tweakblogs.net/blog/cat/716 - -License: MPL 1.1/GPL 2.0/LGPL 2.1 (see sourcecode) - -================================================================================ -VERSION HISTORY -================================================================================ -17-05-2009 - version 1.3 - -- Fixed loop-constructs and if with empty body -- Fixed hook:colon precedence issues (https://bugzilla.mozilla.org/show_bug.cgi?id=492445) -- Combine concats of strings with same quotestyle -- Combine var-statements - --------------------------------------------------------------------------------- -18-04-2009 - version 1.2 - -- Fixed crash in PHP 5.2.9 when matching large comments or strings - (due to PCRE backtracking bug) -- Don't add curly braces around statements for a CASE label -- Always put statements for IF between curly braces when followed by an ELSE -- Save some more bytes by omitting the space between RETURN and the return - expression in certain cases - --------------------------------------------------------------------------------- -12-04-2009 - version 1.1 - -- Improved tokenizer performance by reading smaller chunks for matching -- Bugfix: jumplabels for break/continue statements were not written to output -- Improved stringmatching: cases like '\' and '' now throw unterminated - string literal error -- Fixed linenumber offset bug caused by JScript conditional compilation blocks -- nest() always calls Statement() so no need to use call_user_func() with a parm - --------------------------------------------------------------------------------- -09-04-2009 - version 1.0 - -Initial version - -================================================================================ -KNOWN ISSUES -================================================================================ - -- JScript conditional compilation support is incomplete - -================================================================================ -DOWNLOAD LOCATION -================================================================================ - -Latest version: -version 1.3 : http://files.tweakers.net/jsminplus/jsminplus.zip - -Previous versions: -version 1.2 : http://files.tweakers.net/jsminplus/jsminplus-1.2.zip -version 1.1 : http://files.tweakers.net/jsminplus/jsminplus-1.1.zip -version 1.0 : http://files.tweakers.net/jsminplus/jsminplus-1.0.zip diff --git a/tools/minify/jsminplus/jsminplus.php b/tools/minify/jsminplus/jsminplus.php deleted file mode 100644 index 885edee41..000000000 --- a/tools/minify/jsminplus/jsminplus.php +++ /dev/null @@ -1,1981 +0,0 @@ - */ - -/** - * JSMinPlus version 1.3 - * - * Minifies a javascript file using a javascript parser - * - * This implements a PHP port of Brendan Eich's Narcissus open source javascript engine (in javascript) - * References: http://en.wikipedia.org/wiki/Narcissus_(JavaScript_engine) - * Narcissus sourcecode: http://mxr.mozilla.org/mozilla/source/js/narcissus/ - * JSMinPlus weblog: http://crisp.tweakblogs.net/blog/cat/716 - * - * Tino Zijdel - * - * Usage: $minified = JSMinPlus::minify($script [, $filename]) - * - * Versionlog (see also changelog.txt): - * 17-05-2009 - fixed hook:colon precedence, fixed empty body in loop and if-constructs - * 18-04-2009 - fixed crashbug in PHP 5.2.9 and several other bugfixes - * 12-04-2009 - some small bugfixes and performance improvements - * 09-04-2009 - initial open sourced version 1.0 - * - * Latest version of this script: http://files.tweakers.net/jsminplus/jsminplus.zip - * - */ - -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Narcissus JavaScript engine. - * - * The Initial Developer of the Original Code is - * Brendan Eich . - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Tino Zijdel - * PHP port, modifications and minifier routine are (C) 2009 - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -define('TOKEN_END', 1); -define('TOKEN_NUMBER', 2); -define('TOKEN_IDENTIFIER', 3); -define('TOKEN_STRING', 4); -define('TOKEN_REGEXP', 5); -define('TOKEN_NEWLINE', 6); -define('TOKEN_CONDCOMMENT_START', 7); -define('TOKEN_CONDCOMMENT_END', 8); - -define('JS_SCRIPT', 100); -define('JS_BLOCK', 101); -define('JS_LABEL', 102); -define('JS_FOR_IN', 103); -define('JS_CALL', 104); -define('JS_NEW_WITH_ARGS', 105); -define('JS_INDEX', 106); -define('JS_ARRAY_INIT', 107); -define('JS_OBJECT_INIT', 108); -define('JS_PROPERTY_INIT', 109); -define('JS_GETTER', 110); -define('JS_SETTER', 111); -define('JS_GROUP', 112); -define('JS_LIST', 113); - -define('DECLARED_FORM', 0); -define('EXPRESSED_FORM', 1); -define('STATEMENT_FORM', 2); - -class JSMinPlus -{ - private $parser; - private $reserved = array( - 'break', 'case', 'catch', 'continue', 'default', 'delete', 'do', - 'else', 'finally', 'for', 'function', 'if', 'in', 'instanceof', - 'new', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'var', - 'void', 'while', 'with', - // Words reserved for future use - 'abstract', 'boolean', 'byte', 'char', 'class', 'const', 'debugger', - 'double', 'enum', 'export', 'extends', 'final', 'float', 'goto', - 'implements', 'import', 'int', 'interface', 'long', 'native', - 'package', 'private', 'protected', 'public', 'short', 'static', - 'super', 'synchronized', 'throws', 'transient', 'volatile', - // These are not reserved, but should be taken into account - // in isValidIdentifier (See jslint source code) - 'arguments', 'eval', 'true', 'false', 'Infinity', 'NaN', 'null', 'undefined' - ); - - private function __construct() - { - $this->parser = new JSParser(); - } - - public static function minify($js, $filename='') - { - static $instance; - - // this is a singleton - if(!$instance) - $instance = new JSMinPlus(); - - return $instance->min($js, $filename); - } - - private function min($js, $filename) - { - try - { - $n = $this->parser->parse($js, $filename, 1); - return $this->parseTree($n); - } - catch(Exception $e) - { - echo $e->getMessage() . "\n"; - } - - return false; - } - - private function parseTree($n, $noBlockGrouping = false) - { - $s = ''; - - switch ($n->type) - { - case KEYWORD_FUNCTION: - $s .= 'function' . ($n->name ? ' ' . $n->name : '') . '('; - $params = $n->params; - for ($i = 0, $j = count($params); $i < $j; $i++) - $s .= ($i ? ',' : '') . $params[$i]; - $s .= '){' . $this->parseTree($n->body, true) . '}'; - break; - - case JS_SCRIPT: - // we do nothing with funDecls or varDecls - $noBlockGrouping = true; - // FALL THROUGH - - case JS_BLOCK: - $childs = $n->treeNodes; - $lastType = 0; - for ($c = 0, $i = 0, $j = count($childs); $i < $j; $i++) - { - $type = $childs[$i]->type; - $t = $this->parseTree($childs[$i]); - if (strlen($t)) - { - if ($c) - { - $s = rtrim($s, ';'); - - if ($type == KEYWORD_FUNCTION && $childs[$i]->functionForm == DECLARED_FORM) - { - // put declared functions on a new line - $s .= "\n"; - } - elseif ($type == KEYWORD_VAR && $type == $lastType) - { - // mutiple var-statements can go into one - $t = ',' . substr($t, 4); - } - else - { - // add terminator - $s .= ';'; - } - } - - $s .= $t; - - $c++; - $lastType = $type; - } - } - - if ($c > 1 && !$noBlockGrouping) - { - $s = '{' . $s . '}'; - } - break; - - case KEYWORD_IF: - $s = 'if(' . $this->parseTree($n->condition) . ')'; - $thenPart = $this->parseTree($n->thenPart); - $elsePart = $n->elsePart ? $this->parseTree($n->elsePart) : null; - - // empty if-statement - if ($thenPart == '') - $thenPart = ';'; - - if ($elsePart) - { - // be carefull and always make a block out of the thenPart; could be more optimized but is a lot of trouble - if ($thenPart != ';' && $thenPart[0] != '{') - $thenPart = '{' . $thenPart . '}'; - - $s .= $thenPart . 'else'; - - // we could check for more, but that hardly ever applies so go for performance - if ($elsePart[0] != '{') - $s .= ' '; - - $s .= $elsePart; - } - else - { - $s .= $thenPart; - } - break; - - case KEYWORD_SWITCH: - $s = 'switch(' . $this->parseTree($n->discriminant) . '){'; - $cases = $n->cases; - for ($i = 0, $j = count($cases); $i < $j; $i++) - { - $case = $cases[$i]; - if ($case->type == KEYWORD_CASE) - $s .= 'case' . ($case->caseLabel->type != TOKEN_STRING ? ' ' : '') . $this->parseTree($case->caseLabel) . ':'; - else - $s .= 'default:'; - - $statement = $this->parseTree($case->statements, true); - if ($statement) - { - $s .= $statement; - // no terminator for last statement - if ($i + 1 < $j) - $s .= ';'; - } - } - $s .= '}'; - break; - - case KEYWORD_FOR: - $s = 'for(' . ($n->setup ? $this->parseTree($n->setup) : '') - . ';' . ($n->condition ? $this->parseTree($n->condition) : '') - . ';' . ($n->update ? $this->parseTree($n->update) : '') . ')'; - - $body = $this->parseTree($n->body); - if ($body == '') - $body = ';'; - - $s .= $body; - break; - - case KEYWORD_WHILE: - $s = 'while(' . $this->parseTree($n->condition) . ')'; - - $body = $this->parseTree($n->body); - if ($body == '') - $body = ';'; - - $s .= $body; - break; - - case JS_FOR_IN: - $s = 'for(' . ($n->varDecl ? $this->parseTree($n->varDecl) : $this->parseTree($n->iterator)) . ' in ' . $this->parseTree($n->object) . ')'; - - $body = $this->parseTree($n->body); - if ($body == '') - $body = ';'; - - $s .= $body; - break; - - case KEYWORD_DO: - $s = 'do{' . $this->parseTree($n->body, true) . '}while(' . $this->parseTree($n->condition) . ')'; - break; - - case KEYWORD_BREAK: - case KEYWORD_CONTINUE: - $s = $n->value . ($n->label ? ' ' . $n->label : ''); - break; - - case KEYWORD_TRY: - $s = 'try{' . $this->parseTree($n->tryBlock, true) . '}'; - $catchClauses = $n->catchClauses; - for ($i = 0, $j = count($catchClauses); $i < $j; $i++) - { - $t = $catchClauses[$i]; - $s .= 'catch(' . $t->varName . ($t->guard ? ' if ' . $this->parseTree($t->guard) : '') . '){' . $this->parseTree($t->block, true) . '}'; - } - if ($n->finallyBlock) - $s .= 'finally{' . $this->parseTree($n->finallyBlock, true) . '}'; - break; - - case KEYWORD_THROW: - $s = 'throw ' . $this->parseTree($n->exception); - break; - - case KEYWORD_RETURN: - $s = 'return'; - if ($n->value) - { - $t = $this->parseTree($n->value); - if (strlen($t)) - { - if ( $t[0] != '(' && $t[0] != '[' && $t[0] != '{' && - $t[0] != '"' && $t[0] != "'" && $t[0] != '/' - ) - $s .= ' '; - - $s .= $t; - } - } - break; - - case KEYWORD_WITH: - $s = 'with(' . $this->parseTree($n->object) . ')' . $this->parseTree($n->body); - break; - - case KEYWORD_VAR: - case KEYWORD_CONST: - $s = $n->value . ' '; - $childs = $n->treeNodes; - for ($i = 0, $j = count($childs); $i < $j; $i++) - { - $t = $childs[$i]; - $s .= ($i ? ',' : '') . $t->name; - $u = $t->initializer; - if ($u) - $s .= '=' . $this->parseTree($u); - } - break; - - case KEYWORD_DEBUGGER: - throw new Exception('NOT IMPLEMENTED: DEBUGGER'); - break; - - case TOKEN_CONDCOMMENT_START: - case TOKEN_CONDCOMMENT_END: - $s = $n->value . ($n->type == TOKEN_CONDCOMMENT_START ? ' ' : ''); - $childs = $n->treeNodes; - for ($i = 0, $j = count($childs); $i < $j; $i++) - $s .= $this->parseTree($childs[$i]); - break; - - case OP_SEMICOLON: - if ($expression = $n->expression) - $s = $this->parseTree($expression); - break; - - case JS_LABEL: - $s = $n->label . ':' . $this->parseTree($n->statement); - break; - - case OP_COMMA: - $childs = $n->treeNodes; - for ($i = 0, $j = count($childs); $i < $j; $i++) - $s .= ($i ? ',' : '') . $this->parseTree($childs[$i]); - break; - - case OP_ASSIGN: - $s = $this->parseTree($n->treeNodes[0]) . $n->value . $this->parseTree($n->treeNodes[1]); - break; - - case OP_HOOK: - $s = $this->parseTree($n->treeNodes[0]) . '?' . $this->parseTree($n->treeNodes[1]) . ':' . $this->parseTree($n->treeNodes[2]); - break; - - case OP_OR: case OP_AND: - case OP_BITWISE_OR: case OP_BITWISE_XOR: case OP_BITWISE_AND: - case OP_EQ: case OP_NE: case OP_STRICT_EQ: case OP_STRICT_NE: - case OP_LT: case OP_LE: case OP_GE: case OP_GT: - case OP_LSH: case OP_RSH: case OP_URSH: - case OP_MUL: case OP_DIV: case OP_MOD: - $s = $this->parseTree($n->treeNodes[0]) . $n->type . $this->parseTree($n->treeNodes[1]); - break; - - case OP_PLUS: - case OP_MINUS: - $left = $this->parseTree($n->treeNodes[0]); - $right = $this->parseTree($n->treeNodes[1]); - - switch ($n->treeNodes[1]->type) - { - case OP_PLUS: - case OP_MINUS: - case OP_INCREMENT: - case OP_DECREMENT: - case OP_UNARY_PLUS: - case OP_UNARY_MINUS: - $s = $left . $n->type . ' ' . $right; - break; - - case TOKEN_STRING: - //combine concatted strings with same quotestyle - if ($n->type == OP_PLUS && substr($left, -1) == $right[0]) - { - $s = substr($left, 0, -1) . substr($right, 1); - break; - } - // FALL THROUGH - - default: - $s = $left . $n->type . $right; - } - break; - - case KEYWORD_IN: - $s = $this->parseTree($n->treeNodes[0]) . ' in ' . $this->parseTree($n->treeNodes[1]); - break; - - case KEYWORD_INSTANCEOF: - $s = $this->parseTree($n->treeNodes[0]) . ' instanceof ' . $this->parseTree($n->treeNodes[1]); - break; - - case KEYWORD_DELETE: - $s = 'delete ' . $this->parseTree($n->treeNodes[0]); - break; - - case KEYWORD_VOID: - $s = 'void(' . $this->parseTree($n->treeNodes[0]) . ')'; - break; - - case KEYWORD_TYPEOF: - $s = 'typeof ' . $this->parseTree($n->treeNodes[0]); - break; - - case OP_NOT: - case OP_BITWISE_NOT: - case OP_UNARY_PLUS: - case OP_UNARY_MINUS: - $s = $n->value . $this->parseTree($n->treeNodes[0]); - break; - - case OP_INCREMENT: - case OP_DECREMENT: - if ($n->postfix) - $s = $this->parseTree($n->treeNodes[0]) . $n->value; - else - $s = $n->value . $this->parseTree($n->treeNodes[0]); - break; - - case OP_DOT: - $s = $this->parseTree($n->treeNodes[0]) . '.' . $this->parseTree($n->treeNodes[1]); - break; - - case JS_INDEX: - $s = $this->parseTree($n->treeNodes[0]); - // See if we can replace named index with a dot saving 3 bytes - if ( $n->treeNodes[0]->type == TOKEN_IDENTIFIER && - $n->treeNodes[1]->type == TOKEN_STRING && - $this->isValidIdentifier(substr($n->treeNodes[1]->value, 1, -1)) - ) - $s .= '.' . substr($n->treeNodes[1]->value, 1, -1); - else - $s .= '[' . $this->parseTree($n->treeNodes[1]) . ']'; - break; - - case JS_LIST: - $childs = $n->treeNodes; - for ($i = 0, $j = count($childs); $i < $j; $i++) - $s .= ($i ? ',' : '') . $this->parseTree($childs[$i]); - break; - - case JS_CALL: - $s = $this->parseTree($n->treeNodes[0]) . '(' . $this->parseTree($n->treeNodes[1]) . ')'; - break; - - case KEYWORD_NEW: - case JS_NEW_WITH_ARGS: - $s = 'new ' . $this->parseTree($n->treeNodes[0]) . '(' . ($n->type == JS_NEW_WITH_ARGS ? $this->parseTree($n->treeNodes[1]) : '') . ')'; - break; - - case JS_ARRAY_INIT: - $s = '['; - $childs = $n->treeNodes; - for ($i = 0, $j = count($childs); $i < $j; $i++) - { - $s .= ($i ? ',' : '') . $this->parseTree($childs[$i]); - } - $s .= ']'; - break; - - case JS_OBJECT_INIT: - $s = '{'; - $childs = $n->treeNodes; - for ($i = 0, $j = count($childs); $i < $j; $i++) - { - $t = $childs[$i]; - if ($i) - $s .= ','; - if ($t->type == JS_PROPERTY_INIT) - { - // Ditch the quotes when the index is a valid identifier - if ( $t->treeNodes[0]->type == TOKEN_STRING && - $this->isValidIdentifier(substr($t->treeNodes[0]->value, 1, -1)) - ) - $s .= substr($t->treeNodes[0]->value, 1, -1); - else - $s .= $t->treeNodes[0]->value; - - $s .= ':' . $this->parseTree($t->treeNodes[1]); - } - else - { - $s .= $t->type == JS_GETTER ? 'get' : 'set'; - $s .= ' ' . $t->name . '('; - $params = $t->params; - for ($i = 0, $j = count($params); $i < $j; $i++) - $s .= ($i ? ',' : '') . $params[$i]; - $s .= '){' . $this->parseTree($t->body, true) . '}'; - } - } - $s .= '}'; - break; - - case KEYWORD_NULL: case KEYWORD_THIS: case KEYWORD_TRUE: case KEYWORD_FALSE: - case TOKEN_IDENTIFIER: case TOKEN_NUMBER: case TOKEN_STRING: case TOKEN_REGEXP: - $s = $n->value; - break; - - case JS_GROUP: - $s = '(' . $this->parseTree($n->treeNodes[0]) . ')'; - break; - - default: - throw new Exception('UNKNOWN TOKEN TYPE: ' . $n->type); - } - - return $s; - } - - private function isValidIdentifier($string) - { - return preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $string) && !in_array($string, $this->reserved); - } -} - -class JSParser -{ - private $t; - - private $opPrecedence = array( - ';' => 0, - ',' => 1, - '=' => 2, '?' => 2, ':' => 2, - // The above all have to have the same precedence, see bug 330975 - '||' => 4, - '&&' => 5, - '|' => 6, - '^' => 7, - '&' => 8, - '==' => 9, '!=' => 9, '===' => 9, '!==' => 9, - '<' => 10, '<=' => 10, '>=' => 10, '>' => 10, 'in' => 10, 'instanceof' => 10, - '<<' => 11, '>>' => 11, '>>>' => 11, - '+' => 12, '-' => 12, - '*' => 13, '/' => 13, '%' => 13, - 'delete' => 14, 'void' => 14, 'typeof' => 14, - '!' => 14, '~' => 14, 'U+' => 14, 'U-' => 14, - '++' => 15, '--' => 15, - 'new' => 16, - '.' => 17, - JS_NEW_WITH_ARGS => 0, JS_INDEX => 0, JS_CALL => 0, - JS_ARRAY_INIT => 0, JS_OBJECT_INIT => 0, JS_GROUP => 0 - ); - - private $opArity = array( - ',' => -2, - '=' => 2, - '?' => 3, - '||' => 2, - '&&' => 2, - '|' => 2, - '^' => 2, - '&' => 2, - '==' => 2, '!=' => 2, '===' => 2, '!==' => 2, - '<' => 2, '<=' => 2, '>=' => 2, '>' => 2, 'in' => 2, 'instanceof' => 2, - '<<' => 2, '>>' => 2, '>>>' => 2, - '+' => 2, '-' => 2, - '*' => 2, '/' => 2, '%' => 2, - 'delete' => 1, 'void' => 1, 'typeof' => 1, - '!' => 1, '~' => 1, 'U+' => 1, 'U-' => 1, - '++' => 1, '--' => 1, - 'new' => 1, - '.' => 2, - JS_NEW_WITH_ARGS => 2, JS_INDEX => 2, JS_CALL => 2, - JS_ARRAY_INIT => 1, JS_OBJECT_INIT => 1, JS_GROUP => 1, - TOKEN_CONDCOMMENT_START => 1, TOKEN_CONDCOMMENT_END => 1 - ); - - public function __construct() - { - $this->t = new JSTokenizer(); - } - - public function parse($s, $f, $l) - { - // initialize tokenizer - $this->t->init($s, $f, $l); - - $x = new JSCompilerContext(false); - $n = $this->Script($x); - if (!$this->t->isDone()) - throw $this->t->newSyntaxError('Syntax error'); - - return $n; - } - - private function Script($x) - { - $n = $this->Statements($x); - $n->type = JS_SCRIPT; - $n->funDecls = $x->funDecls; - $n->varDecls = $x->varDecls; - - return $n; - } - - private function Statements($x) - { - $n = new JSNode($this->t, JS_BLOCK); - array_push($x->stmtStack, $n); - - while (!$this->t->isDone() && $this->t->peek() != OP_RIGHT_CURLY) - $n->addNode($this->Statement($x)); - - array_pop($x->stmtStack); - - return $n; - } - - private function Block($x) - { - $this->t->mustMatch(OP_LEFT_CURLY); - $n = $this->Statements($x); - $this->t->mustMatch(OP_RIGHT_CURLY); - - return $n; - } - - private function Statement($x) - { - $tt = $this->t->get(); - $n2 = null; - - // Cases for statements ending in a right curly return early, avoiding the - // common semicolon insertion magic after this switch. - switch ($tt) - { - case KEYWORD_FUNCTION: - return $this->FunctionDefinition( - $x, - true, - count($x->stmtStack) > 1 ? STATEMENT_FORM : DECLARED_FORM - ); - break; - - case OP_LEFT_CURLY: - $n = $this->Statements($x); - $this->t->mustMatch(OP_RIGHT_CURLY); - return $n; - - case KEYWORD_IF: - $n = new JSNode($this->t); - $n->condition = $this->ParenExpression($x); - array_push($x->stmtStack, $n); - $n->thenPart = $this->Statement($x); - $n->elsePart = $this->t->match(KEYWORD_ELSE) ? $this->Statement($x) : null; - array_pop($x->stmtStack); - return $n; - - case KEYWORD_SWITCH: - $n = new JSNode($this->t); - $this->t->mustMatch(OP_LEFT_PAREN); - $n->discriminant = $this->Expression($x); - $this->t->mustMatch(OP_RIGHT_PAREN); - $n->cases = array(); - $n->defaultIndex = -1; - - array_push($x->stmtStack, $n); - - $this->t->mustMatch(OP_LEFT_CURLY); - - while (($tt = $this->t->get()) != OP_RIGHT_CURLY) - { - switch ($tt) - { - case KEYWORD_DEFAULT: - if ($n->defaultIndex >= 0) - throw $this->t->newSyntaxError('More than one switch default'); - // FALL THROUGH - case KEYWORD_CASE: - $n2 = new JSNode($this->t); - if ($tt == KEYWORD_DEFAULT) - $n->defaultIndex = count($n->cases); - else - $n2->caseLabel = $this->Expression($x, OP_COLON); - break; - default: - throw $this->t->newSyntaxError('Invalid switch case'); - } - - $this->t->mustMatch(OP_COLON); - $n2->statements = new JSNode($this->t, JS_BLOCK); - while (($tt = $this->t->peek()) != KEYWORD_CASE && $tt != KEYWORD_DEFAULT && $tt != OP_RIGHT_CURLY) - $n2->statements->addNode($this->Statement($x)); - - array_push($n->cases, $n2); - } - - array_pop($x->stmtStack); - return $n; - - case KEYWORD_FOR: - $n = new JSNode($this->t); - $n->isLoop = true; - $this->t->mustMatch(OP_LEFT_PAREN); - - if (($tt = $this->t->peek()) != OP_SEMICOLON) - { - $x->inForLoopInit = true; - if ($tt == KEYWORD_VAR || $tt == KEYWORD_CONST) - { - $this->t->get(); - $n2 = $this->Variables($x); - } - else - { - $n2 = $this->Expression($x); - } - $x->inForLoopInit = false; - } - - if ($n2 && $this->t->match(KEYWORD_IN)) - { - $n->type = JS_FOR_IN; - if ($n2->type == KEYWORD_VAR) - { - if (count($n2->treeNodes) != 1) - { - throw $this->t->SyntaxError( - 'Invalid for..in left-hand side', - $this->t->filename, - $n2->lineno - ); - } - - // NB: n2[0].type == IDENTIFIER and n2[0].value == n2[0].name. - $n->iterator = $n2->treeNodes[0]; - $n->varDecl = $n2; - } - else - { - $n->iterator = $n2; - $n->varDecl = null; - } - - $n->object = $this->Expression($x); - } - else - { - $n->setup = $n2 ? $n2 : null; - $this->t->mustMatch(OP_SEMICOLON); - $n->condition = $this->t->peek() == OP_SEMICOLON ? null : $this->Expression($x); - $this->t->mustMatch(OP_SEMICOLON); - $n->update = $this->t->peek() == OP_RIGHT_PAREN ? null : $this->Expression($x); - } - - $this->t->mustMatch(OP_RIGHT_PAREN); - $n->body = $this->nest($x, $n); - return $n; - - case KEYWORD_WHILE: - $n = new JSNode($this->t); - $n->isLoop = true; - $n->condition = $this->ParenExpression($x); - $n->body = $this->nest($x, $n); - return $n; - - case KEYWORD_DO: - $n = new JSNode($this->t); - $n->isLoop = true; - $n->body = $this->nest($x, $n, KEYWORD_WHILE); - $n->condition = $this->ParenExpression($x); - if (!$x->ecmaStrictMode) - { - //