Add .env support.

This commit is contained in:
marco
2015-07-21 18:20:38 +02:00
parent 05af63dc00
commit f5cb2467ea
6 changed files with 75 additions and 23 deletions

1
.env.sample Normal file
View File

@@ -0,0 +1 @@
WP_TEST_URL="http://localhost"

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ tests/_output/*
bower_components/* bower_components/*
node_modules node_modules
tests/*.suite.yml tests/*.suite.yml
.env

View File

@@ -1,4 +1,8 @@
<?php <?php
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
class RoboFile extends \Robo\Tasks { class RoboFile extends \Robo\Tasks {
function install() { function install() {
$this->_exec('./composer.phar install'); $this->_exec('./composer.phar install');
@@ -6,35 +10,31 @@ class RoboFile extends \Robo\Tasks {
} }
function update() { function update() {
$this->say(getenv('WP_TEST_URL'));
$this->_exec('./composer.phar update'); $this->_exec('./composer.phar update');
$this->_exec('npm 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() { function testUnit() {
$this->_exec('vendor/bin/codecept run unit'); $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() { function testAcceptance() {
if($this->testAcceptanceConfig()) { $this->loadEnv();
$this $this
->taskExec('phantomjs --webdriver=4444') ->taskExec('phantomjs --webdriver=4444')
->background() ->background()
->run(); ->run();
sleep(2); sleep(2);
$this->_exec('vendor/bin/codecept run acceptance'); $this->_exec('vendor/bin/codecept run acceptance');
}
} }
function testAll() { function testAll() {
$this->loadEnv();
$this $this
->taskexec('phantomjs --webdriver=4444') ->taskexec('phantomjs --webdriver=4444')
->background() ->background()
@@ -43,7 +43,10 @@ class RoboFile extends \Robo\Tasks {
$this->_exec('vendor/bin/codecept run'); $this->_exec('vendor/bin/codecept run');
} }
function watch() { function loadEnv() {
$this->_exec('./node_modules/stylus/bin/stylus -u nib -w assets/css/src/admin.styl -o assets/css/'); $this->taskReplaceInFile('tests/acceptance.suite.yml')
->regex("/url.*/")
->to('url: ' . "'" . getenv('WP_TEST_URL'). "'")
->run();
} }
} }

View File

@@ -8,7 +8,8 @@
"codeception/codeception": "*", "codeception/codeception": "*",
"codeception/specify": "*", "codeception/specify": "*",
"codeception/verify": "*", "codeception/verify": "*",
"codegyre/robo": "*" "codegyre/robo": "*",
"vlucas/phpdotenv": "*"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

48
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "d120ce6897bd8803e0dcface16642b8b", "hash": "8868736a7d968f4adddfcd0c607810ae",
"packages": [ "packages": [
{ {
"name": "phpmailer/phpmailer", "name": "phpmailer/phpmailer",
@@ -2110,6 +2110,52 @@
"description": "Symfony Yaml Component", "description": "Symfony Yaml Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2015-07-01 11:25:50" "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": [], "aliases": [],

View File

@@ -1,4 +1,4 @@
<?php //[STAMP] b7decc66e5ef5eaba3d375be7320376b <?php //[STAMP] 9cd003010af5e6228d99a8c6909f010e
namespace _generated; namespace _generated;
// This class was automatically generated by build task // This class was automatically generated by build task
@@ -8,7 +8,7 @@ namespace _generated;
use Codeception\Module\WebDriver; use Codeception\Module\WebDriver;
use Helper\Acceptance; use Helper\Acceptance;
trait AcceptanceTesterActions trait acceptancetesterActions
{ {
/** /**
* @return \Codeception\Scenario * @return \Codeception\Scenario