-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move C3 code to separate class #72
Conversation
Basic usage: ``` require __DIR__ . '/vendor/codeception/c3/c3.php'; $c3 = new Codeception\C3(__DIR__); $c3->run(); ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update Setup instructions in README and document how to use c3 with codecept.phar file.
) { | ||
ini_set('memory_limit', $requiredMemory); | ||
} | ||
// Autoload Codeception classes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new major version that requires composer, so it would be better to make it depend on Codeception ^5.0 and remove this require block because functions will be loaded by Composer automatically.
Update: If codecept.phar file is used, we have to require codecept.phar/vendor/autoload.php file instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not using Composer autoloader and directly including the file should still work, for example:
require __DIR__ . '/vendor/codeception/c3/c3.php';
$c3 = new Codeception\C3(__DIR__); // pass the directory that contains Codeception config files
$c3->run();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or do you mean that since this will be a new major version of c3, more legacy loading methods can be removed?
Also - I don't know when Codeception v5 will be out, but it's probably better if we can keep support for Codeception v4 as well?
define('C3_CODECOVERAGE_PROJECT_ROOT', Codeception\Configuration::projectDir()); | ||
define('C3_CODECOVERAGE_TESTNAME', $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE']); | ||
// phpunit codecoverage shimming | ||
if (!class_exists('PHP_CodeCoverage') and class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These class aliases were used to support PHPUnit <5.4. They can be removed now.
class_alias('SebastianBergmann\CodeCoverage\Exception', 'PHP_CodeCoverage_Exception'); | ||
} | ||
// phpunit version | ||
if (!class_exists('PHPUnit_Runner_Version') && class_exists('PHPUnit\Runner\Version')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHPUnit 5 compatibility
Thanks @marcovtwout Looks really nice! I like the idea but it must be tested very well before releasing. Unfortunately, we have only basic tests on Codeception Ci pipeline. |
@DavertMik Thanks for the feedback :) Here's a preview with some of the improvements I mentioned already applied: https://github.com/marcovtwout/c3/pull/1/commits Since you are thinking about a new major version anyways, perhaps legacy compatibility parts can be removed as well? |
@DavertMik @Naktibalda I revisited this PR after some time has passed. Seems to me this is still a good basis for further improvements. I created a new PR basing the same changes on the actual version of |
This PR is a first step in improving #40
Instead of having a copy of
c3.php
in the project root it can be included from any location.Basic usage:
I only made the minimal changes to test this concept. Best to disable whitespace comparison when reviewing this PR.
There's more to be improved after this:
__c3_
-functions part of the classBut first I like to get feedback on the current changes and to check if there's any use cases I might have missed.