diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000000..3691e9f596 --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ +WP_TEST_URL="http://localhost" diff --git a/.gitignore b/.gitignore index 390273a3b5..e1a1062a15 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ tests/_output/* bower_components/* node_modules tests/*.suite.yml +.env diff --git a/RoboFile.php b/RoboFile.php index f57d4b660b..c27a6322e7 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -1,4 +1,8 @@ load(); + class RoboFile extends \Robo\Tasks { function install() { $this->_exec('./composer.phar install'); @@ -6,35 +10,31 @@ class RoboFile extends \Robo\Tasks { } function update() { + $this->say(getenv('WP_TEST_URL')); $this->_exec('./composer.phar update'); $this->_exec('npm update'); } + function watch() { + $this->_exec('./node_modules/stylus/bin/stylus -u nib -w assets/css/src/admin.styl -o assets/css/'); + } + function testUnit() { $this->_exec('vendor/bin/codecept run unit'); } - function testAcceptanceConfig() { - // create config file from sample unless a config file alread exists - return $this->_copy( - 'tests/acceptance.suite.yml.sample', - 'tests/acceptance.suite.yml', - true - ); - } - function testAcceptance() { - if($this->testAcceptanceConfig()) { - $this - ->taskExec('phantomjs --webdriver=4444') - ->background() - ->run(); - sleep(2); - $this->_exec('vendor/bin/codecept run acceptance'); - } + $this->loadEnv(); + $this + ->taskExec('phantomjs --webdriver=4444') + ->background() + ->run(); + sleep(2); + $this->_exec('vendor/bin/codecept run acceptance'); } function testAll() { + $this->loadEnv(); $this ->taskexec('phantomjs --webdriver=4444') ->background() @@ -43,7 +43,10 @@ class RoboFile extends \Robo\Tasks { $this->_exec('vendor/bin/codecept run'); } - function watch() { - $this->_exec('./node_modules/stylus/bin/stylus -u nib -w assets/css/src/admin.styl -o assets/css/'); + function loadEnv() { + $this->taskReplaceInFile('tests/acceptance.suite.yml') + ->regex("/url.*/") + ->to('url: ' . "'" . getenv('WP_TEST_URL'). "'") + ->run(); } } diff --git a/composer.json b/composer.json index d7378362db..499a856079 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,8 @@ "codeception/codeception": "*", "codeception/specify": "*", "codeception/verify": "*", - "codegyre/robo": "*" + "codegyre/robo": "*", + "vlucas/phpdotenv": "*" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 425f9c718b..b981ab8e8e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "d120ce6897bd8803e0dcface16642b8b", + "hash": "8868736a7d968f4adddfcd0c607810ae", "packages": [ { "name": "phpmailer/phpmailer", @@ -2110,6 +2110,52 @@ "description": "Symfony Yaml Component", "homepage": "https://symfony.com", "time": "2015-07-01 11:25:50" + }, + { + "name": "vlucas/phpdotenv", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "91064290f5b53a09bdff1b939d7f69fb0e7531b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/91064290f5b53a09bdff1b939d7f69fb0e7531b5", + "reference": "91064290f5b53a09bdff1b939d7f69fb0e7531b5", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "authors": [ + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "http://www.vancelucas.com" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "homepage": "http://github.com/vlucas/phpdotenv", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "time": "2015-05-30 16:15:01" } ], "aliases": [], diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php index 6260e4c097..ce737ad95d 100644 --- a/tests/_support/_generated/AcceptanceTesterActions.php +++ b/tests/_support/_generated/AcceptanceTesterActions.php @@ -1,4 +1,4 @@ -