Skip to content
Permalink
Browse files

Set up config file; use composer install

  • Loading branch information...
danielbachhuber committed Aug 2, 2014
1 parent 3c6748e commit 8c9a51ec7926c7f78180410d89c4347343bee272
Showing with 48 additions and 5 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 .travis.yml
  3. +19 −4 bin/install-package-tests.sh
  4. +3 −0 composer.json
  5. +23 −0 utils/get-package-require-from-composer.php
@@ -1,2 +1,4 @@
behat.phar
composer.phar
/vendor
.DS_Store
@@ -11,4 +11,4 @@ env:
before_script:
- bash bin/install-package-tests.sh

script: php behat.phar
script: ./vendor/bin/behat
@@ -2,6 +2,9 @@

set -ex

PACKAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../ && pwd )"
PACKAGE_TEST_CONFIG_PATH=$WP_CLI_BIN_DIR/config.yml

install_wp_cli() {

# the Behat test suite will pick up the executable found in $WP_CLI_BIN_DIR
@@ -12,12 +15,23 @@ install_wp_cli() {

}

set_package_context() {

touch $PACKAGE_TEST_CONFIG_PATH
printf 'require:' > $PACKAGE_TEST_CONFIG_PATH
requires=$(php $PACKAGE_DIR/utils/get-package-require-from-composer.php composer.json)
for require in "${requires[@]}"
do
printf "$config_file\n%2s-%1s$PACKAGE_DIR/$require" >> $PACKAGE_TEST_CONFIG_PATH
done

}

download_behat() {

cd ../
# Latest build URL causes OpenSSL issues on Travis :/
wget https://github.com/Behat/Behat/releases/download/v3.0.12/behat.phar
chmod +x behat.phar
cd $PACKAGE_DIR
curl -s https://getcomposer.org/installer | php
php composer.phar require --dev behat/behat='~2.5'

}

@@ -27,5 +41,6 @@ install_db() {
}

install_wp_cli
set_package_context
download_behat
install_db
@@ -16,5 +16,8 @@
},
"autoload": {
"files": [ "dictator.php" ]
},
"require-dev": {
"behat/behat": "~2.5"
}
}
@@ -0,0 +1,23 @@
<?php
$file = $argv[1];
if ( ! file_exists( $file ) ) {
echo 'File does not exist.';
exit(1);
}
$contents = file_get_contents( $file );
$composer = json_decode( $contents );
if ( empty( $composer ) || ! is_object( $composer ) ) {
echo 'Invalid composer.json for package.';
exit(1);
}
if ( empty( $composer->autoload->files ) ) {
echo 'composer.json must specify valid "autoload" => "files"';
exit(1);
}
echo implode( PHP_EOL, $composer->autoload->files );
exit(0);

0 comments on commit 8c9a51e

Please sign in to comment.
You can’t perform that action at this time.