Skip to content

Commit

Permalink
Merge pull request #6067 from Naktibalda/5.0
Browse files Browse the repository at this point in the history
Codeception 5.0
  • Loading branch information
DavertMik committed Jan 2, 2021
2 parents e817f83 + f3ce511 commit 8d6b2dc
Show file tree
Hide file tree
Showing 83 changed files with 4,688 additions and 373 deletions.
38 changes: 23 additions & 15 deletions .github/workflows/build.yml
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0"]
php: ["7.3", "7.4", "8.0"]

steps:
- name: Checkout
Expand Down Expand Up @@ -53,28 +53,37 @@ jobs:
run: composer validate

- name: Composer install
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
run: composer install --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run tests PHP 5.6, 7.0, 7.1, 7.3
if: matrix.php == '56' || matrix.php == '7.0' || matrix.php == '7.1' || matrix.php == '7.3'
- name: Run tests without code coverage on PHP 7.3, 7.4
if: matrix.php == '7.3' || matrix.php == '7.4'
run: |
php -S 127.0.0.1:8000 -t tests/data/app >/dev/null 2>&1 &
php -S 127.0.0.1:8008 -t tests/data/app >/dev/null 2>&1 &
php codecept build
php codecept run cli,unit
- name: Run tests PHP 7.2, 7.4
if: matrix.php == '7.2' || matrix.php == '7.4'
- name: Run tests with code coverage on PHP 7.2, 8.0
if: matrix.php == '7.2' || matrix.php == '8.0'
run: |
php -S 127.0.0.1:8000 -t tests/data/app -d pcov.directory=$(pwd)/tests/data/app >/dev/null 2>&1 &
php -S 127.0.0.1:8008 -t tests/data/app -d pcov.directory=$(pwd)/tests/data/app >/dev/null 2>&1 &
php codecept build
php codecept run cli,unit,coverage --env COVERAGE=1
- name: Run tests PHP 8.0
if: matrix.php == '8.0'
- name: Run module-asserts tests
run: php codecept run -c vendor/codeception/module-asserts/

- name: Run module-filesystem tests
run: php codecept run -c vendor/codeception/module-filesystem/

- name: Run module-db sqlite tests
run: php codecept run -c vendor/codeception/module-db/ unit :Sqlite

- name: Run module-phpbrowser tests
run: |
php -S 127.0.0.1:8000 -t tests/data/app -d pcov.directory=$(pwd)/tests/data/app >/dev/null 2>&1 &
php codecept build
php codecept run cli,unit,coverage --env COVERAGE=1
cd vendor/codeception/module-phpbrowser/
php -S 127.0.0.1:8000 -t tests/data/app >/dev/null 2>&1 &
php -S 127.0.0.1:8010 -t tests/data/rest >/dev/null 2>&1 &
php ../../../codecept run tests/unit/Codeception/Module/PhpBrowserTest.php
windows-latest:
name: PHP ${{ matrix.php }}-${{ matrix.os }}
Expand All @@ -89,8 +98,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest]

php: ["7.0", "7.1", "7.2", "7.3", "7.4", "8.0"]
php: ["7.3", "7.4", "8.0"]

steps:
- name: Checkout
Expand Down
78 changes: 0 additions & 78 deletions autoload.php
Expand Up @@ -35,8 +35,6 @@
}

// @codingStandardsIgnoreStart

include_once __DIR__ . DIRECTORY_SEPARATOR . 'shim.php';
// compat
if (PHP_MAJOR_VERSION < 7) {
if (false === interface_exists('Throwable', false)) {
Expand All @@ -47,79 +45,3 @@ class ParseError extends \Exception {};
}
}
// @codingStandardsIgnoreEnd

// function not autoloaded in PHP, thus its a good place for them
if (!function_exists('codecept_debug')) {
function codecept_debug($data)
{
\Codeception\Util\Debug::debug($data);
}
}

if (!function_exists('codecept_root_dir')) {
function codecept_root_dir($appendPath = '')
{
return \Codeception\Configuration::projectDir() . $appendPath;
}
}

if (!function_exists('codecept_output_dir')) {
function codecept_output_dir($appendPath = '')
{
return \Codeception\Configuration::outputDir() . $appendPath;
}
}

if (!function_exists('codecept_log_dir')) {
function codecept_log_dir($appendPath = '')
{
return \Codeception\Configuration::outputDir() . $appendPath;
}
}

if (!function_exists('codecept_data_dir')) {
function codecept_data_dir($appendPath = '')
{
return \Codeception\Configuration::dataDir() . $appendPath;
}
}

if (!function_exists('codecept_relative_path')) {
function codecept_relative_path($path)
{
return \Codeception\Util\PathResolver::getRelativeDir(
$path,
\Codeception\Configuration::projectDir(),
DIRECTORY_SEPARATOR
);
}
}

if (!function_exists('codecept_absolute_path')) {
/**
* If $path is absolute, it will be returned without changes.
* If $path is relative, it will be passed to `codecept_root_dir()` function
* to make it absolute.
*
* @param string $path
* @return string the absolute path
*/
function codecept_absolute_path($path)
{
return codecept_is_path_absolute($path) ? $path : codecept_root_dir($path);
}
}

if (!function_exists('codecept_is_path_absolute')) {
/**
* Check whether the given $path is absolute.
*
* @param string $path
* @return bool
* @since 2.4.4
*/
function codecept_is_path_absolute($path)
{
return \Codeception\Util\PathResolver::isPathAbsolute($path);
}
}
40 changes: 22 additions & 18 deletions composer.json
Expand Up @@ -15,27 +15,24 @@
"minimum-stability": "RC",

"require": {
"php": ">=5.6.0 <9.0",
"php": ">=7.3.0 <9.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"codeception/lib-asserts": "^1.0",
"guzzlehttp/psr7": "~1.4",
"symfony/finder": ">=2.7 <6.0",
"symfony/console": ">=2.7 <6.0",
"symfony/event-dispatcher": ">=2.7 <6.0",
"symfony/yaml": ">=2.7 <6.0",
"symfony/css-selector": ">=2.7 <6.0",
"behat/gherkin": "^4.4.0",
"codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.1.1 | ^9.0",
"codeception/stub": "^2.0 | ^3.0"
"phpunit/phpunit": "^9.5",
"codeception/lib-asserts": "^1.13",
"guzzlehttp/psr7": "^1.7",
"symfony/finder": ">=4.4 <6.0",
"symfony/console": ">=4.4 <6.0",
"symfony/event-dispatcher": ">=4.4 <6.0",
"symfony/yaml": ">=4.4 <6.0",
"symfony/css-selector": ">=4.4 <6.0",
"behat/gherkin": "^4.6.2",
"codeception/stub": "^3.7"
},
"require-dev": {
"monolog/monolog": "~1.8",
"codeception/specify": "~0.3",
"squizlabs/php_codesniffer": "~2.0",
"vlucas/phpdotenv": "^2.0 | ^3.0 | ^4.0 | ^5.0",
"symfony/process": ">=2.7 <6.0",
"vlucas/phpdotenv": "^4.0 | ^5.0",
"symfony/process": ">=4.4 <6.0",
"codeception/module-asserts": "*@dev",
"codeception/module-cli": "*@dev",
"codeception/module-db": "*@dev",
Expand All @@ -50,10 +47,17 @@
"symfony/phpunit-bridge": "For phpunit-bridge support",
"stecman/symfony-console-completion": "For BASH autocompletion"
},
"replace": {
"codeception/phpunit-wrapper": "*"
},

"autoload":{
"psr-4":{
"autoload": {
"files": [
"functions.php"
],
"psr-4": {
"Codeception\\": "src/Codeception",
"Codeception\\PHPUnit\\": "src/PHPUnit",
"Codeception\\Extension\\": "ext"
}
},
Expand Down
62 changes: 62 additions & 0 deletions functions.php
@@ -0,0 +1,62 @@
<?php

// function not autoloaded in PHP, thus its a good place for them
function codecept_debug($data)
{
\Codeception\Util\Debug::debug($data);
}

function codecept_root_dir($appendPath = '')
{
return \Codeception\Configuration::projectDir() . $appendPath;
}

function codecept_output_dir($appendPath = '')
{
return \Codeception\Configuration::outputDir() . $appendPath;
}

function codecept_log_dir($appendPath = '')
{
return \Codeception\Configuration::outputDir() . $appendPath;
}


function codecept_data_dir($appendPath = '')
{
return \Codeception\Configuration::dataDir() . $appendPath;
}

function codecept_relative_path($path)
{
return \Codeception\Util\PathResolver::getRelativeDir(
$path,
\Codeception\Configuration::projectDir(),
DIRECTORY_SEPARATOR
);
}

/**
* If $path is absolute, it will be returned without changes.
* If $path is relative, it will be passed to `codecept_root_dir()` function
* to make it absolute.
*
* @param string $path
* @return string the absolute path
*/
function codecept_absolute_path($path)
{
return codecept_is_path_absolute($path) ? $path : codecept_root_dir($path);
}

/**
* Check whether the given $path is absolute.
*
* @param string $path
* @return bool
* @since 2.4.4
*/
function codecept_is_path_absolute($path)
{
return \Codeception\Util\PathResolver::isPathAbsolute($path);
}
43 changes: 0 additions & 43 deletions shim.php

This file was deleted.

10 changes: 1 addition & 9 deletions src/Codeception/Codecept.php
@@ -1,15 +1,12 @@
<?php
namespace Codeception;

use Codeception\Event\DispatcherWrapper;
use Codeception\Exception\ConfigurationException;
use Codeception\Subscriber\ExtensionLoader;
use Symfony\Component\EventDispatcher\EventDispatcher;

class Codecept
{
use DispatcherWrapper;

const VERSION = '4.1.13';

/**
Expand All @@ -21,11 +18,6 @@ class Codecept
*/
protected $result;

/**
* @var \Codeception\CodeCoverage
*/
protected $coverage;

/**
* @var \Symfony\Component\EventDispatcher\EventDispatcher
*/
Expand Down Expand Up @@ -222,7 +214,7 @@ public function printResult()
$printer = $this->runner->getPrinter();
$printer->printResult($result);

$this->dispatch($this->dispatcher, Events::RESULT_PRINT_AFTER, new Event\PrintResultEvent($result, $printer));
$this->dispatcher->dispatch(new Event\PrintResultEvent($result, $printer), Events::RESULT_PRINT_AFTER);
}

/**
Expand Down
7 changes: 2 additions & 5 deletions src/Codeception/Command/CompletionFallback.php
Expand Up @@ -27,11 +27,8 @@ protected function configure()
END
);

// Hide this command from listing if supported
// Command::setHidden() was not available before Symfony 3.2.0
if (method_exists($this, 'setHidden')) {
$this->setHidden(true);
}
// Hide this command from listing
$this->setHidden(true);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand Down

0 comments on commit 8d6b2dc

Please sign in to comment.