Skip to content

Commit

Permalink
Merge pull request #411 from Restless-ET/master
Browse files Browse the repository at this point in the history
Created helpful bash script for running tests locally.
  • Loading branch information
K-Phoen committed Jul 2, 2015
2 parents d6a9730 + be0b97b commit 04c208e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Tests/autoload.php
nbproject
catalog.xml
.idea
composer.phar
composer.lock
vendor/*
!vendor/vendors.php
14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,19 @@ Thank you!
## Running the test suite

Ensure that the required vendors are installed by running `composer install`.
The test suite requires the `php5-mongo` extension to be installed.
The test suite requires the `php5-mongo` and `php5-sqlite` extensions to be installed.

PHPUnit should be installed by composer. Run the tests with the
`./vendor/bin/phpunit` command.

Alternatively you can use the `runTests.sh` bash script present at the project root.
Default usage example:

```~$ ./runTest.sh``` (This runs all tests with your current PHP version against all supported Symfony versions.)

You can also set a specific Symfony version to test against and/or pass the arguments for PHPUnit
as arguments to the script. Usage example:

```~$ SYMFONY_VERSION=2.7.1 ./runTests.sh --filter testCustomFileNameProperty```

**Note:** The script was prepared to run under Ubuntu and using Bash so it might need further validation for other OS.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"ocramius/proxy-manager": "~0.5"
},
"require-dev": {
"ext-sqlite3" : "*",

"doctrine/mongodb-odm": "@dev",
"knplabs/knp-gaufrette-bundle": "*",
"oneup/flysystem-bundle": "dev-master",
Expand Down
40 changes: 40 additions & 0 deletions runTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
#

SUPPORTED_SYMFONY_VERSIONS=('~2.3.0' '~2.5.0' '~2.6.0' '~2.7.0' '2.8.x-dev')
DOCTRINE_VERSION=">=2.2.3,<2.5-dev"

restore_composer (){
# Restore the composer.json file
rm composer.json && mv composer.json.bck composer.json
}

# Install/upgrade composer.phar
curl -sS https://getcomposer.org/installer | php
php composer.phar --version

# Save a copy of the current composer.json file so we can restore it later
cp composer.json composer.json.bck

# Clear temp folder before the tests run
rm -rf /tmp/VichUploaderBundle/

# If SYMFONY_VERSION is set run the tests only for that version
if [ "${SYMFONY_VERSION}" != "" ]; then
SUPPORTED_SYMFONY_VERSIONS=(${SYMFONY_VERSION})
fi

# Run the tests for each supported symfony version
for sf_version in ${SUPPORTED_SYMFONY_VERSIONS[@]}; do
echo -e "\n\nSetting requirements version constraints: Symfony (${sf_version}) and Doctrine (${DOCTRINE_VERSION})"
php composer.phar require --no-update "symfony/symfony":"${sf_version}"
php composer.phar require --no-update "doctrine/orm":"${DOCTRINE_VERSION}"

echo -e "\nInstalling dependencies"
php composer.phar update --prefer-source || { restore_composer && exit 1; }

echo -e "\nLaunching tests"
vendor/bin/phpunit $@
done

restore_composer

0 comments on commit 04c208e

Please sign in to comment.