Codeception Composer Project Module
Create throw away composer projects for Codeception tests.
- Why?
- The Goals, or What This Module Does?
- Install
- Config
- API
- Frequently Asked Questions
- Support!
- Developing
- Running the Tests
- Feedback
- Change log
- Security
- Contributing
- Credits
- License
Why?
Because it good to test your code in a more realistic environment.
The Goals, or What This Module Does?
Create throw away composer projects for Codeception tests.
Before each test:
- Copy composer project files to a temporary directory
- Config local packages paths
- Install package via composer
- Change directory into the temporary directory
After each test:
- Delete the temporary directory
Install
Installation should be done via composer, details of how to install composer can be found at https://getcomposer.org/.
$ composer require typisttech/codeception-composer-project-module --devConfig
In your Codeception config file (e.g: acceptance.suite.yml or acceptance.yml):
This is the minimal config:
modules:
enabled:
- ComposerProject:
projectRoot: 'path/to/composer/project'
depends:
- Cli
- FilesystemThis is the full config:
modules:
enabled:
- ComposerProject:
projectRoot: 'path/to/composer/project'
composerInstallFlags: '--no-interaction --quiet'
symlink: 'true'
repositoryPaths:
- 'tests/_data/dummy'
- 'tests/_data/another-dummy'
depends:
- Cli
- FilesystemprojectRoot
Required String
Example: tests/_data/project
Path to the composer project directory, relative to the root directory (where codeception.yml is located).
This directory must contain a composer.json file.
composerInstallFlags
Optional String
Example: --no-interaction --verbose --no-ansi
Default: --no-interaction --quiet
Extra flags to pass in during composer install.
symlink
Optional Boolean in single quotes
Example: 'false'
Default: 'true'
Should the local packages be symlink-ed or not.
See: Composer document
repositoryPaths
Optional Array of strings
Example:
- 'tests/_data/dummy'
- 'tests/_data/another-dummy'Default: The root directory (where codeception.yml is located).
Paths to local packages, relative to the root directory (where codeception.yml is located).
See: Composer document
API
amInTmpProjectDir
Change directory to the temporary project directory
- @return void
Example:
$I->amInTmpProjectDir();runComposerCommand
Run a composer command
- @param string $command
- @param bool $failNonZero Optional. Default: true Fails If exit code is > 0.
- @return void
Example:
$I->runComposerCommand('update --verbose');
// This is equivalent to running `$ composer update --verbose` in the console.runComposerInstall
Run composer install with composerInstallFlags
- @return void
Example:
$I->runComposerInstall();getTmpProjectDir()
Get the path to the temporary project directory
Note: Return value maybe a symbolic link.
- @return string
Example:
$I->getTmpProjectDir();
// To ensure real path:
$tmpProjectDir = $I->getTmpProjectDir();
$tmpProjectDir = realpath($tmpProjectDir);Frequently Asked Questions
I want to see what Codeception Composer Project Module have done for me?
Run the tests with the --debug flag.
Codeception Composer Project Module will log debug message to the console.
What to do when composer install fail or not install the latest version?
Your requirements could not be resolved to an installable set of packages.
Make sure you have package version constraints and minimum stability set up correctly.
{
"require": {
"dummy/dummy": "*"
},
"minimum-stability": "dev"
}What to do when the tests are too slow?
- Enable symlink
- Add
--prefer-distto composerInstallFlags - Add
"prefer-stable": truetocomposer.json
Note: These methods might not suitable for your use case.
Does it works on codeception/base?
Yes. This module works on both codeception/codeception and codeception/base
Do you have real life examples that use this composer plugin?
Here you go:
Add your own here
Support!
Donate via PayPal 
Love Codeception Composer Project Module? Help me maintain Codeception Composer Project Module, a donation here can help with it.
Donate Monero
Send Monero to my public address: 43fiS7JzAK7eSHCpjTL5J1JYqPb6pvM2dGex7aoFZ5u5e5QRg6NKNnFGXqPh6C53E3M8UvqzemVt43uLgimwDpW41zXUHAp
Mine me some Monero
- Open one of the follow web pages open on your computer
- Start the miner
- Adjust threads and CPU usages
- Keep it running
If you have an AdBlocker:
else:
Why don't you hire me?
Ready to take freelance WordPress jobs. Contact me via the contact form here or, via email info@typist.tech
Want to help in other way? Want to be a sponsor?
Contact: Tang Rufus
Developing
To setup a developer workable version you should run these commands:
$ composer create-project --keep-vcs --no-install typisttech/codeception-composer-project-module:dev-master
$ cd codeception-composer-project-module
$ composer installRunning the Tests
Codeception Composer Project Module run tests on Codeception.
Run the tests:
$ composer testWe also test all PHP files against PSR-2: Coding Style Guide.
Check the code style with $ composer check-style and fix it with $ composer fix-style.
Feedback
Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.
Change log
Please see CHANGELOG for more information on what has changed recently.
Security
If you discover any security related issues, please email codeception-composer-project-module@typist.tech instead of using the issue tracker.
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Credits
Codeception Composer Project Module is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.
Full list of contributors can be found here.
License
The MIT License (MIT). Please see License File for more information.
