# Codeception Composer Project Module
[![Packagist Version](https://img.shields.io/packagist/v/typisttech/codeception-composer-project-module.svg?style=flat-square)](https://packagist.org/packages/typisttech/codeception-composer-project-module)
[![Packagist Downloads](https://img.shields.io/packagist/dt/typisttech/codeception-composer-project-module.svg?style=flat-square)](https://packagist.org/packages/typisttech/codeception-composer-project-module)
[![PHP from Packagist](https://img.shields.io/packagist/php-v/TypistTech/codeception-composer-project-module?style=flat-square)](https://packagist.org/packages/typisttech/codeception-composer-project-module)
[![CircleCI](https://img.shields.io/circleci/build/gh/TypistTech/codeception-composer-project-module?style=flat-square)](https://circleci.com/gh/TypistTech/codeception-composer-project-module)
[![license](https://img.shields.io/github/license/TypistTech/codeception-composer-project-module.svg?style=flat-square)](https://github.com/TypistTech/codeception-composer-project-module/blob/master/LICENSE)
[![Twitter Follow @TangRufus](https://img.shields.io/twitter/follow/TangRufus?style=flat-square&color=1da1f2&logo=twitter)](https://twitter.com/tangrufus)
[![Hire Typist Tech](https://img.shields.io/badge/Hire-Typist%20Tech-ff69b4.svg?style=flat-square)](https://www.typist.tech/contact/)
Create throw away composer projects for Codeception tests.
Built with ♥ by Typist Tech
, (*1)
Codeception Composer Project Module is an open source project and completely free to use., (*2)
However, the amount of effort needed to maintain and develop new features is not sustainable without proper financial backing. If you have the capability, please consider donating using the links below:, (*3)
[![GitHub via Sponsor](https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?style=flat-square&logo=github)](https://github.com/sponsors/TangRufus)
[![Sponsor via PayPal](https://img.shields.io/badge/Sponsor-PayPal-blue.svg?style=flat-square&logo=paypal)](https://typist.tech/go/paypal-donate/)
[![More Sponsorship Information](https://img.shields.io/badge/Sponsor-More%20Details-ff69b4?style=flat-square)](https://typist.tech/donate/codeception-composer-project-module/)
Create throw away composer projects for Codeception tests., (*4)
Why?
Because it's good to test your composer plugins in a more realistic environment., (*5)
The Goals, or What This Module Does?
Create throw away composer projects for Codeception tests., (*6)
Before each test:, (*7)
- Copy dummy composer project files to a temporary directory
- Config local packages paths
- Install package via composer
- Change directory into the temporary directory
After each test:, (*8)
- Delete the temporary directory
Install
composer require --dev typisttech/codeception-composer-project-module
Config
In your Codeception config file (e.g: acceptance.suite.yml
or acceptance.yml
):, (*9)
This is the minimal config:, (*10)
modules:
enabled:
- ComposerProject:
projectRoot: 'path/to/composer/project'
depends:
- Cli
- Filesystem
This is the full config:, (*11)
modules:
enabled:
- ComposerProject:
projectRoot: 'path/to/composer/project'
composerInstallFlags: '--no-interaction --quiet'
symlink: 'true'
repositoryPaths:
- 'tests/_data/dummy'
- 'tests/_data/another-dummy'
depends:
- Cli
- Filesystem
projectRoot
Required String, (*12)
Example: tests/_data/project
, (*13)
Path to the composer project directory, relative to the root directory (where codeception.yml
is located).
This directory must contain a composer.json
file., (*14)
composerInstallFlags
Optional String, (*15)
Example: --no-interaction --verbose --no-ansi
, (*16)
Default: --no-interaction --quiet
, (*17)
Extra flags to pass in during composer install
., (*18)
See: $ composer help install, (*19)
symlink
Optional Boolean in single quotes, (*20)
Example: 'false'
, (*21)
Default: 'true'
, (*22)
Should the local packages be symlink-ed or not., (*23)
See: Composer document, (*24)
repositoryPaths
Optional Array of strings, (*25)
Example:, (*26)
- 'tests/_data/dummy'
- 'tests/_data/another-dummy'
Default: The root directory (where codeception.yml
is located)., (*27)
Paths to local packages, relative to the root directory (where codeception.yml
is located)., (*28)
See: Composer document, (*29)
Typist Tech is ready to build your next awesome WordPress site. Hire us!
, (*30)
API
amInTmpProjectDir
Change directory to the temporary project directory, (*31)
Example:, (*32)
$I->amInTmpProjectDir();
runComposerCommand
Run a composer command, (*33)
- @param string $command
- @param bool $failNonZero Optional. Default: true
Fails If exit code is > 0.
- @return void
Example:, (*34)
// This is equivalent to running `$ composer update --verbose` in the console.
$I->runComposerCommand('update --verbose');
runComposerInstall
Run composer install
with composerInstallFlags
, (*35)
Example:, (*36)
$I->runComposerInstall();
getTmpProjectDir()
Get the path to the temporary project directory, (*37)
Note: Return value maybe a symbolic link., (*38)
Example:, (*39)
$I->getTmpProjectDir();
// To ensure real path:
$tmpProjectDir = $I->getTmpProjectDir();
$tmpProjectDir = realpath($tmpProjectDir);
Frequently Asked Questions
Which composer versions are supported?
Both v1 and v2., (*40)
I want to see what Codeception Composer Project Module have done for me?
Run the tests with the --debug
flag., (*41)
Codeception Composer Project Module will log debug message to the console., (*42)
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., (*43)
Make sure you have package version constraints and minimum stability set up correctly., (*44)
{
"require": {
"dummy/dummy": "*"
},
"minimum-stability": "dev"
}
What to do when the tests are too slow?
Note: These methods are not suitable for every use case., (*45)
Do you have real life examples that use this composer plugin?
Here you go:, (*46)
Will you add support for older PHP versions?
Never! This plugin will only work on actively supported PHP versions., (*49)
Don't use it on end of life or security fixes only PHP versions., (*50)
It looks awesome. Where can I find some more goodies like this
Where can I give 5-star reviews?
Thanks! Glad you like it. It's important to let me knows somebody is using this project. Please consider:, (*51)
Testing
composer test
composer style:check
Feedback
Please provide feedback! We want to make this project as useful as possible.
Please submit an issue and point out what you do and don't like, or fork the project and send pull requests.
No issue is too small., (*52)
Security Vulnerabilities
If you discover a security vulnerability within this project, please email us at codeception-composer-project-module@typist.tech.
All security vulnerabilities will be promptly addressed., (*53)
Credits
Codeception Composer Project Module is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire., (*54)
Full list of contributors can be found here., (*55)
License
Codeception Composer Project Module is released under the MIT License., (*56)