├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── composer.json ├── sample ├── .gitignore ├── codeception.yml ├── composer.json └── tests │ ├── _bootstrap.php │ ├── _data │ └── dump.sql │ ├── _support │ ├── AcceptanceTester.php │ ├── FunctionalTester.php │ ├── Helper │ │ ├── Acceptance.php │ │ ├── Functional.php │ │ └── Unit.php │ └── UnitTester.php │ ├── acceptance.suite.yml │ ├── acceptance │ ├── AcceptanceTestCest.php │ └── _bootstrap.php │ ├── functional.suite.yml │ ├── functional │ ├── FunctionalTestCest.php │ └── _bootstrap.php │ ├── unit.suite.yml │ └── unit │ ├── UnitTestCest.php │ └── _bootstrap.php ├── src └── EventsScripting.php └── test ├── .gitignore ├── codeception.yml ├── composer.json └── tests ├── _bootstrap.php ├── _data └── dump.sql ├── _support ├── AcceptanceTester.php ├── FunctionalTester.php ├── Helper │ ├── Acceptance.php │ ├── Functional.php │ └── Unit.php └── UnitTester.php ├── acceptance.suite.yml ├── acceptance ├── AcceptanceTestCest.php └── _bootstrap.php ├── functional.suite.yml ├── functional └── _bootstrap.php ├── unit.suite.yml └── unit └── _bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.vim 3 | 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | branches: 4 | # Only test the master branch and SemVer tags. 5 | only: 6 | - master 7 | - /^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/ 8 | 9 | php: 10 | - 5.5 11 | - 5.6 12 | - 7.0 13 | - hhvm 14 | 15 | sudo: false 16 | 17 | cache: 18 | directories: 19 | - test/vendor 20 | - sample/vendor 21 | - $HOME/.composer/cache 22 | 23 | before_script: 24 | - if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi 25 | - cd sample 26 | - 'if [ "$TRAVIS_PHP_VERSION" = "5.4" ]; then rm composer.lock; fi' 27 | - composer install -n --prefer-source 28 | - cd ../test 29 | - 'if [ "$TRAVIS_PHP_VERSION" = "5.4" ]; then rm composer.lock; fi' 30 | - composer install -n --prefer-source 31 | - cd ../ 32 | 33 | script: 34 | - cd test 35 | - ./vendor/bin/codecept run 36 | 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | T License (MIT) 2 | 3 | Copyright (c) 2016 Oleksii Prudkyi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **oprudkyi/codeception-events-scripting** The [Codeception](http://codeception.com/) extension 2 | for automatically running shell scripts on codeception events. 3 | 4 | [![Latest Stable Version](https://poser.pugx.org/oprudkyi/codeception-events-scripting/v/stable)](https://packagist.org/packages/oprudkyi/codeception-events-scripting) 5 | [![Total Downloads](https://poser.pugx.org/oprudkyi/codeception-events-scripting/downloads)](https://packagist.org/packages/oprudkyi/codeception-events-scripting) 6 | [![License](https://poser.pugx.org/oprudkyi/codeception-events-scripting/license)](https://packagist.org/packages/oprudkyi/codeception-events-scripting) 7 | [![Build Status](https://travis-ci.org/oprudkyi/codeception-events-scripting.svg?branch=master)](https://travis-ci.org/oprudkyi/codeception-events-scripting) 8 | 9 | ## About 10 | 11 | Run shell scripts on codeception's events - before/after tests/suites (like db seeding, stopping-running additional software etc.) 12 | Inspired by [Phantoman](https://github.com/site5/phantoman) extension for [Codeception](http://codeception.com/), though allow to run anything in more generic way. 13 | 14 | ## Minimum Requirements 15 | 16 | - Codeception 2.1.0 17 | - PHP 5.5 18 | 19 | ## Installation 20 | 21 | This project can be installed via [Composer](http://getcomposer.org). 22 | To get the latest version, simply add the following line to 23 | the require block of your composer.json file: 24 | 25 | { 26 | "require-dev": { 27 | "oprudkyi/codeception-events-scripting": "*" 28 | } 29 | 30 | } 31 | 32 | You'll then need to run `composer install` or `composer update` to download the 33 | package and have the autoloader updated. 34 | 35 | Or run the following command: 36 | 37 | ```sh 38 | composer require oprudkyi/codeception-events-scripting --dev 39 | ``` 40 | 41 | 42 | ## Configuration 43 | 44 | Enable extension in the codeception.yml and write commands. 45 | Next events are supported: 46 | - BeforeAll - run before tests on every "codecept run" 47 | - AfterAll - run after all tests 48 | - BeforeSuite - run before each suite (use 'suites' array to run only for selected suites) 49 | - AfterSuite - run after each suite (use 'suites' array to run only for selected suites) 50 | 51 | supported next attributes: 52 | - command - command line to run (for one-liners you can write command directly) 53 | - description - echoed before command 54 | - params - additional params for command 55 | - ignoreErrors - don't break testing if command fails (failed or retval != 0) 56 | - suites - single name or array of suites to run command for (applied to base name, like 'acceptance' as well to long name 'acceptance (phantom, firefox)') 57 | - environments - single name or array of environments 58 | - platforms - single name or array of platforms (uses `PHP_OS` constant, i.e. the platform where PHP was built, check [here](http://php.net/manual/en/function.php-uname.php) for details) 59 | 60 | 61 | ```yml 62 | extensions: 63 | enabled: 64 | - Codeception\Extension\EventsScripting 65 | config: 66 | Codeception\Extension\EventsScripting: 67 | BeforeAll: 68 | - command: echo "Before All" 69 | - command: echo "Before All with Description" 70 | description: Description of command 71 | - echo "Before All single line" 72 | - command: echo 73 | params: "Before All Params" 74 | description: Before All with Params 75 | - command: "false" 76 | description: BeforeAll. fail on run but ignore errors 77 | ignoreErrors: true 78 | AfterAll: 79 | - command: echo "After All" 80 | - command: uname 81 | description: Platform *nx-like 82 | platforms: [darwin, linux, bsd, unix] 83 | - command: ver 84 | description: Platform Windows 85 | platforms: windows 86 | BeforeSuite: 87 | - command: echo "Before acceptance suite" 88 | suites: ['acceptance'] 89 | - command: echo "Before any suite" 90 | - command: echo "Before acceptance suite, phantom environment" 91 | suites: ['acceptance'] 92 | environments: phantom 93 | - command: echo "Before acceptance suite, phantom,chrome environments" 94 | suites: ['acceptance'] 95 | environments: ['phantom', 'chrome'] 96 | AfterSuite: 97 | - command: echo "After acceptance suite" 98 | suites: 'acceptance' 99 | - command: echo "After any suite" 100 | 101 | ``` 102 | 103 | Real example (start/stop mailcatcher and seed db): 104 | ```yml 105 | Codeception\Extension\EventsScripting: 106 | BeforeAll: 107 | - command: ./artisan db:seed-test --env=testing 108 | description: Reset db and seed 109 | BeforeSuite: 110 | - command: GEM_HOME=vendor/ruby vendor/ruby/bin/mailcatcher --ip 127.0.0.1 --smtp-port 11031 --http-port 11091 111 | suites: 'acceptance' 112 | description: Start mailcatcher 113 | AfterSuite: 114 | - command: curl -s -X DELETE http://127.0.0.1:11091 115 | suites: 'acceptance' 116 | description: Stop mailcatcher 117 | ignoreErrors: true 118 | 119 | ``` 120 | 121 | ## Testing 122 | 123 | ```sh 124 | cd sample 125 | composer install -n --prefer-source 126 | cd ../test 127 | composer install -n --prefer-source 128 | ./vendor/bin/codecept run 129 | ``` 130 | 131 | ## Contribute 132 | 133 | This package is (yet) under development and refactoring but is ready for 134 | production. Please, feel free to comment, contribute and help. I will be happy 135 | to get some help to deliver tests. 136 | 137 | ## License 138 | 139 | Codeception's events scripting is licensed under [The MIT License (MIT)](LICENSE). 140 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oprudkyi/codeception-events-scripting", 3 | "description": "The Codeception extension for automatically running shell scripts on codeception events", 4 | "keywords": ["codeception", "extension", "shell"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Oleksii Prudkyi", 9 | "email": "Oleksii.Prudkyi@gmail.com" 10 | } 11 | ], 12 | "require": { 13 | "php": ">=5.5.9", 14 | "codeception/codeception": "^5.0" 15 | }, 16 | "autoload": { 17 | "psr-4": { 18 | "Codeception\\Extension\\": "src/" 19 | } 20 | }, 21 | "config": { 22 | "preferred-install": "dev" 23 | }, 24 | "minimum-stability": "dev", 25 | "prefer-stable": true 26 | } 27 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | tests/_output/* 3 | composer.lock 4 | tests/_support/_generated/ 5 | 6 | -------------------------------------------------------------------------------- /sample/codeception.yml: -------------------------------------------------------------------------------- 1 | actor: Tester 2 | paths: 3 | tests: tests 4 | log: tests/_output 5 | data: tests/_data 6 | support: tests/_support 7 | envs: tests/_envs 8 | settings: 9 | bootstrap: _bootstrap.php 10 | colors: true 11 | memory_limit: 1024M 12 | extensions: 13 | enabled: 14 | - Codeception\Extension\EventsScripting 15 | config: 16 | Codeception\Extension\EventsScripting: 17 | BeforeAll: 18 | - command: echo "Before All" 19 | - command: echo "Before All with Description" 20 | description: Description of command 21 | - echo "Before All single line" 22 | - command: echo 23 | params: "Before All Params" 24 | description: Before All with Params 25 | - command: "false" 26 | description: BeforeAll. fail on run but ignore errors 27 | ignoreErrors: true 28 | - command: echo "Before All suite with phantom environment" 29 | environments: phantom 30 | AfterAll: 31 | - command: echo "After All" 32 | - command: uname 33 | description: Platform *nx-like 34 | platforms: [darwin, linux, bsd, unix] 35 | - command: ver 36 | description: Platform Windows 37 | platforms: windows 38 | - command: echo "After All suite with phantom,chrome environments" 39 | environments: ['phantom', 'chrome'] 40 | BeforeSuite: 41 | - command: echo "Before acceptance suite" 42 | suites: ['acceptance'] 43 | - command: echo "Before any suite" 44 | - command: echo "Before acceptance suite, phantom environment" 45 | suites: ['acceptance'] 46 | environments: phantom 47 | - command: echo "Before acceptance suite, phantom,chrome environments" 48 | suites: ['acceptance'] 49 | environments: ['phantom', 'chrome'] 50 | AfterSuite: 51 | - command: echo "After acceptance suite" 52 | suites: 'acceptance' 53 | - command: echo "After any suite" 54 | modules: 55 | config: 56 | Db: 57 | dsn: '' 58 | user: '' 59 | password: '' 60 | dump: tests/_data/dump.sql 61 | -------------------------------------------------------------------------------- /sample/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "codeception/codeception": "*" 4 | }, 5 | "autoload": { 6 | "psr-4": { 7 | "Codeception\\Extension\\": "../src/" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /sample/tests/_bootstrap.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | 11 | namespace Codeception\Extension; 12 | 13 | use Codeception\Exception\ExtensionException; 14 | 15 | class EventsScripting extends \Codeception\Extension 16 | { 17 | // list events to listen to 18 | public static $events = array( 19 | //run before any tests 20 | 'module.init' => 'beforeModule', 21 | 22 | //Before suite is executed 23 | 'suite.before' => 'beforeSuite', 24 | 25 | //After suite was executed 26 | 'suite.after' => 'afterSuite', 27 | ); 28 | 29 | public function __construct($config, $options) 30 | { 31 | parent::__construct($config, $options); 32 | } 33 | 34 | public function __destruct() 35 | { 36 | $this->afterModule(); 37 | } 38 | 39 | /** 40 | * run command 41 | */ 42 | private function runSimpleCommand($command, $description, $ignoreErrors) 43 | { 44 | $this->writeln("Starting : {$description}"); 45 | $lastLine = system($command, $retval); 46 | if($lastLine === FALSE) { 47 | $this->writeln("Command failed"); 48 | if(!$ignoreErrors) { 49 | throw new ExtensionException($this, "Command {$command} failed"); 50 | } 51 | } 52 | if($retval !== 0) { 53 | $this->writeln("Command result code : {$retval}"); 54 | if(!$ignoreErrors) { 55 | throw new ExtensionException($this, "Command result code : {$retval}"); 56 | } 57 | } 58 | } 59 | 60 | private function processCommand($command) 61 | { 62 | if(is_string($command)) { 63 | $this->runSimpleCommand($command, $command, false); 64 | } else if(is_array($command)) { 65 | //extract params 66 | if(!isset($command['command'])) { 67 | throw new ExtensionException($this, "'command' value is expected, get : \r\n" . print_r($command, true)); 68 | } 69 | $commandLine = $command['command']; 70 | 71 | $ignoreErrors = false; 72 | if(isset($command['ignoreErrors'])) { 73 | $ignoreErrors = (bool)$command['ignoreErrors']; 74 | } 75 | 76 | if(isset($command['params'])) { 77 | $commandLine .= " " . $command['params']; 78 | } 79 | 80 | $description = $commandLine; 81 | if(isset($command['description'])) { 82 | $description = $command['description']; 83 | } 84 | 85 | // check if current OS is supported 86 | if(isset($command['platforms'])) { 87 | if(!$this->isPlatformSupported($command['platforms'])) { 88 | return; 89 | } 90 | } 91 | 92 | // check if environments are supported 93 | if(isset($command['environments'])) { 94 | if(!$this->isEnvironmentSupported($command['environments'])) { 95 | return; 96 | } 97 | } 98 | 99 | if(!empty($this->currentSuite) && isset($command['suites'])) { 100 | $suites = $command['suites']; 101 | if(is_string($suites)) { 102 | $suites = [$suites]; 103 | } 104 | //skip command, it's not for current suite 105 | if(!in_array($this->currentSuite, $suites) 106 | && !in_array($this->currentSuiteBaseName, $suites) 107 | ) { 108 | return; 109 | } 110 | } 111 | 112 | $this->runSimpleCommand($commandLine, $description, $ignoreErrors); 113 | } else { 114 | $type = gettype($command); 115 | throw new ExtensionException($this, "Command type '{$type}' is not supported, string or array is expected"); 116 | } 117 | } 118 | 119 | private function isPlatformSupported($platforms) 120 | { 121 | $platformSupported = false; // default value 122 | 123 | if(is_string($platforms)) { 124 | $platforms = [$platforms]; 125 | } 126 | foreach($platforms as $platform) { 127 | $platformSupported = preg_match("/{$platform}/i", PHP_OS); 128 | if ($platformSupported) { 129 | break; 130 | } 131 | } 132 | return $platformSupported; 133 | } 134 | 135 | private function isEnvironmentSupported($environments) 136 | { 137 | $environmentSupported = false; 138 | 139 | // if beforeAll or afterAll then use complete list of env 140 | if ($this->beforeAllWereRun !== true) { 141 | $selectedEnvironments = $this->options['env']; 142 | if (!empty($selectedEnvironments)) { 143 | $envArray = []; 144 | foreach (array_unique($selectedEnvironments) as $envList) { 145 | $envArray = array_merge($envArray, explode(',', $envList)); 146 | } 147 | } else { 148 | return $environmentSupported; 149 | } 150 | // else use environments from current run instance 151 | } else { 152 | $envArray = $this->currentEnvironment; 153 | } 154 | 155 | if(is_string($environments)) { 156 | $environments = [$environments]; 157 | } 158 | foreach($environments as $environment) { 159 | if(in_array($environment, $envArray)) { 160 | $environmentSupported = true; 161 | break; 162 | } 163 | } 164 | 165 | return $environmentSupported; 166 | 167 | } 168 | 169 | /** 170 | * run each command 171 | */ 172 | private function runCommands(array $commands) 173 | { 174 | foreach($commands as $command) { 175 | $this->processCommand($command); 176 | } 177 | } 178 | 179 | /** 180 | * exctract and run config group (like BeforeAll) 181 | */ 182 | private function runConfigGroup($groupName) 183 | { 184 | if(!isset($this->config[$groupName])) { 185 | return; 186 | } 187 | 188 | $commands = &$this->config[$groupName]; 189 | if(!is_array($commands)) { 190 | throw new ExtensionException($this, "EventScripting config error. {$groupName} should be array"); 191 | } 192 | 193 | $this->runCommands($commands); 194 | } 195 | 196 | // methods that handle events 197 | 198 | private $beforeAllWereRun = false; 199 | 200 | /** 201 | * Module Init, run before any tests 202 | */ 203 | public function beforeModule(\Codeception\Event\SuiteEvent $e) 204 | { 205 | if($this->beforeAllWereRun == false) { 206 | $this->runConfigGroup('BeforeAll'); 207 | $this->beforeAllWereRun = true; 208 | } 209 | } 210 | 211 | //may contain environment names, like 'acceptance (phantom)' or 'acceptance (phantom, chrome)' 212 | private $currentSuite = ''; 213 | 214 | //top level name - acceptance, functional 215 | private $currentSuiteBaseName = ''; 216 | 217 | //array with environments enabled 218 | private $currentEnvironment = []; 219 | 220 | /** 221 | * Module After, run after any tests 222 | */ 223 | public function afterModule() 224 | { 225 | $this->currentSuite = ''; 226 | $this->currentSuiteBaseName = ''; 227 | $this->currentEnvironment = []; 228 | $this->beforeAllWereRun = false; 229 | $this->runConfigGroup('AfterAll'); 230 | } 231 | 232 | /** 233 | * Before suite is executed 234 | */ 235 | public function beforeSuite(\Codeception\Event\SuiteEvent $e) 236 | { 237 | $this->currentSuite = $e->getSuite()->getName(); 238 | $this->currentSuiteBaseName = $e->getSuite()->getBaseName(); 239 | $settings = $e->getSettings(); 240 | if(isset($settings['current_environment'])) { 241 | $this->currentEnvironment = explode(',', $settings['current_environment']); 242 | } else { 243 | $this->currentEnvironment = []; 244 | } 245 | $this->runConfigGroup('BeforeSuite'); 246 | } 247 | 248 | /** 249 | * After suite is executed 250 | */ 251 | public function afterSuite(\Codeception\Event\SuiteEvent $e) 252 | { 253 | $this->runConfigGroup('AfterSuite'); 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | tests/_output/* 3 | composer.lock 4 | tests/_support/_generated/ 5 | 6 | -------------------------------------------------------------------------------- /test/codeception.yml: -------------------------------------------------------------------------------- 1 | actor: Tester 2 | paths: 3 | tests: tests 4 | log: tests/_output 5 | data: tests/_data 6 | support: tests/_support 7 | envs: tests/_envs 8 | settings: 9 | bootstrap: _bootstrap.php 10 | colors: true 11 | memory_limit: 1024M 12 | extensions: 13 | enabled: 14 | - Codeception\Extension\RunFailed 15 | modules: 16 | config: 17 | Db: 18 | dsn: '' 19 | user: '' 20 | password: '' 21 | dump: tests/_data/dump.sql 22 | -------------------------------------------------------------------------------- /test/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "codeception/codeception": "*" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/tests/_bootstrap.php: -------------------------------------------------------------------------------- 1 | runShellCommand('./vendor/bin/codecept run functional --no-colors'); 73 | $I->seeInShellOutput("Functional Tests"); 74 | $I->dontSeeInShellOutput("Acceptance Tests"); 75 | $I->seeInShellOutput($this->beforeAllSmall); 76 | $I->seeInShellOutput($this->beforeAll); 77 | $I->seeInShellOutput($this->beforeAnySuite); 78 | $I->seeInShellOutput($this->afterAnySuite); 79 | $I->seeInShellOutput($this->afterAll); 80 | $I->dontSeeInShellOutput($this->beforeAcceptanceSuite); 81 | $I->dontSeeInShellOutput($this->afterAcceptanceSuite); 82 | $I->dontSeeInShellOutput($this->twoEnvironmentsOut); 83 | $I->dontSeeInShellOutput($this->oneEnvironmentsOut); 84 | $I->seeInShellOutput(PHP_OS); 85 | $I->dontSeeInShellOutput($this->beforeAllEnv); 86 | $I->dontSeeInShellOutput($this->afterAllEnv); 87 | chdir('../test/'); 88 | } 89 | 90 | public function withSuitedCommandsTest(AcceptanceTester $I) 91 | { 92 | chdir('../sample/'); 93 | $I->runShellCommand('./vendor/bin/codecept run acceptance --no-colors'); 94 | $I->dontSeeInShellOutput("Functional Tests"); 95 | $I->seeInShellOutput("Acceptance Tests"); 96 | $I->seeInShellOutput($this->beforeAllSmall); 97 | $I->seeInShellOutput($this->beforeAll); 98 | $I->seeInShellOutput($this->beforeAnySuite); 99 | $I->seeInShellOutput($this->afterAnySuite); 100 | $I->seeInShellOutput($this->afterAll); 101 | $I->seeInShellOutput($this->beforeAcceptanceSuite); 102 | $I->seeInShellOutput($this->afterAcceptanceSuite); 103 | $I->dontSeeInShellOutput($this->twoEnvironmentsOut); 104 | $I->dontSeeInShellOutput($this->oneEnvironmentsOut); 105 | $I->seeInShellOutput(PHP_OS); 106 | $I->dontSeeInShellOutput($this->beforeAllEnv); 107 | chdir('../test/'); 108 | } 109 | 110 | public function fullCommandsTest(AcceptanceTester $I) 111 | { 112 | chdir('../sample/'); 113 | $I->runShellCommand('./vendor/bin/codecept run --no-colors'); 114 | $I->seeInShellOutput("Functional Tests"); 115 | $I->seeInShellOutput("Acceptance Tests"); 116 | $I->seeInShellOutput($this->beforeAllSmall); 117 | $I->seeInShellOutput($this->beforeAll); 118 | $I->seeInShellOutput($this->beforeAnySuite); 119 | $I->seeInShellOutput($this->afterAnySuite); 120 | $I->seeInShellOutput($this->afterAll); 121 | $I->seeInShellOutput($this->beforeAcceptanceSuite); 122 | $I->seeInShellOutput($this->afterAcceptanceSuite); 123 | $I->dontSeeInShellOutput($this->twoEnvironmentsOut); 124 | $I->dontSeeInShellOutput($this->oneEnvironmentsOut); 125 | $I->seeInShellOutput(PHP_OS); 126 | $I->dontSeeInShellOutput($this->beforeAllEnv); 127 | $I->dontSeeInShellOutput($this->afterAllEnv); 128 | chdir('../test/'); 129 | } 130 | 131 | public function withSuitedEnvironmentNoCommandsTest(AcceptanceTester $I) 132 | { 133 | chdir('../sample/'); 134 | $I->runShellCommand('./vendor/bin/codecept run acceptance --env firefox --no-colors'); 135 | $I->dontSeeInShellOutput("Functional Tests"); 136 | $I->seeInShellOutput("Acceptance (firefox) Tests"); 137 | $I->seeInShellOutput($this->beforeAllSmall); 138 | $I->seeInShellOutput($this->beforeAll); 139 | $I->seeInShellOutput($this->beforeAnySuite); 140 | $I->seeInShellOutput($this->afterAnySuite); 141 | $I->seeInShellOutput($this->afterAll); 142 | $I->seeInShellOutput($this->beforeAcceptanceSuite); 143 | $I->seeInShellOutput($this->afterAcceptanceSuite); 144 | $I->dontSeeInShellOutput($this->twoEnvironmentsOut); 145 | $I->dontSeeInShellOutput($this->oneEnvironmentsOut); 146 | $I->seeInShellOutput(PHP_OS); 147 | $I->dontSeeInShellOutput($this->beforeAllEnv); 148 | $I->dontSeeInShellOutput($this->afterAllEnv); 149 | chdir('../test/'); 150 | } 151 | 152 | private $twoEnvironmentsOut = <<<'EOF' 153 | Starting : echo "Before acceptance suite, phantom,chrome environments" 154 | Before acceptance suite, phantom,chrome environments 155 | EOF; 156 | 157 | public function withSuitedEnvironmentOneCommandsTest(AcceptanceTester $I) 158 | { 159 | chdir('../sample/'); 160 | $I->runShellCommand('./vendor/bin/codecept run acceptance --env chrome --no-colors'); 161 | $I->dontSeeInShellOutput("Functional Tests"); 162 | $I->seeInShellOutput("Acceptance (chrome) Tests"); 163 | $I->seeInShellOutput($this->beforeAllSmall); 164 | $I->seeInShellOutput($this->beforeAll); 165 | $I->seeInShellOutput($this->beforeAnySuite); 166 | $I->seeInShellOutput($this->afterAnySuite); 167 | $I->seeInShellOutput($this->afterAll); 168 | $I->seeInShellOutput($this->beforeAcceptanceSuite); 169 | $I->seeInShellOutput($this->afterAcceptanceSuite); 170 | $I->seeInShellOutput($this->twoEnvironmentsOut); 171 | $I->dontSeeInShellOutput($this->oneEnvironmentsOut); 172 | $I->seeInShellOutput(PHP_OS); 173 | $I->dontSeeInShellOutput($this->beforeAllEnv); 174 | $I->seeInShellOutput($this->afterAllEnv); 175 | chdir('../test/'); 176 | } 177 | 178 | private $oneEnvironmentsOut = <<<'EOF' 179 | Starting : echo "Before acceptance suite, phantom environment" 180 | Before acceptance suite, phantom environment 181 | EOF; 182 | 183 | public function withSuitedEnvironmentTwoCommandsTest(AcceptanceTester $I) 184 | { 185 | chdir('../sample/'); 186 | $I->runShellCommand('./vendor/bin/codecept run acceptance --env phantom,firefox --no-colors'); 187 | $I->dontSeeInShellOutput("Functional Tests"); 188 | $I->seeInShellOutput("Acceptance (phantom, firefox) Tests"); 189 | $I->seeInShellOutput($this->beforeAllSmall); 190 | $I->seeInShellOutput($this->beforeAll); 191 | $I->seeInShellOutput($this->beforeAnySuite); 192 | $I->seeInShellOutput($this->afterAnySuite); 193 | $I->seeInShellOutput($this->afterAll); 194 | $I->seeInShellOutput($this->beforeAcceptanceSuite); 195 | $I->seeInShellOutput($this->afterAcceptanceSuite); 196 | $I->seeInShellOutput($this->twoEnvironmentsOut); 197 | $I->seeInShellOutput($this->oneEnvironmentsOut); 198 | $I->seeInShellOutput(PHP_OS); 199 | $I->seeInShellOutput($this->beforeAllEnv); 200 | $I->seeInShellOutput($this->afterAllEnv); 201 | chdir('../test/'); 202 | } 203 | 204 | } 205 | -------------------------------------------------------------------------------- /test/tests/acceptance/_bootstrap.php: -------------------------------------------------------------------------------- 1 |