diff --git a/README.md b/README.md index a37b9262c..9b3f2658c 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,35 @@ heroku config:add BUILDPACK_URL=git://github.com/iphoting/heroku-buildpack-php-t Push deploy your app and you should see Nginx, mcrypt, and PHP being bundled. + +Testing the Buildpack +--------------------- +Setup the test environment on Heroku as follows: +``` +$ cd heroku-buildpack-php-tyler/ +$ heroku create -s cedar -b git://github.com/ryanbrainard/heroku-buildpack-testrunner.git +Creating deep-thought-1234... done, stack is cedar +http://deep-thought-1234.herokuapp.com/ | git@heroku.com:deep-thought-1234.git +Git remote heroku added +``` + +Then, push the buildpack to be tested into Heroku: +``` +$ git push -f heroku :master # where is the git branch you want to test. +``` + +Finally, run those tests: +``` +$ heroku run tests +``` + +If you run your tests programatically, you might need the follow command instead: +``` +$ heroku run tests | bin/report +``` + +Source: + Credits ------- diff --git a/test/compile_test.sh b/test/compile_test.sh new file mode 100644 index 000000000..a958fbf02 --- /dev/null +++ b/test/compile_test.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh + +. ${BUILDPACK_HOME}/support/set-env.sh + +testCompile() +{ + compile + + assertCapturedSuccess + + assertCaptured "-----> Installing Nginx" + assertCaptured "-----> Bundling Nginx v${NGINX_VERSION}" + assertTrue "nginx should be executable" "[ -x ${BUILD_DIR}/vendor/nginx/sbin/nginx ]" + + assertCaptured "-----> Installing libmcrypt" + assertCaptured "-----> Bundling libmcrypt v${LIBMCRYPT_VERSION}" + assertTrue "libmcrypt should exist" "[ -e ${BUILD_DIR}/local/lib/libmcrypt.so ]" + + assertCaptured "-----> Installing libmemcached" + assertCaptured "-----> Bundling libmemcached v${LIBMEMCACHED_VERSION}" + assertTrue "libmemcached should exist" "[ -e ${BUILD_DIR}/local/lib/libmemcached.so ]" + + assertCaptured "-----> Installing PHP" + assertCaptured "-----> Bundling PHP v${PHP_VERSION}" + assertTrue "php-fpm should be executable" "[ -x ${BUILD_DIR}/vendor/php/sbin/php-fpm ]" + + assertCaptured "-----> Installing newrelic" + assertCaptured "-----> Bundling newrelic daemon v${NEWRELIC_VERSION}" + assertTrue "newrelic-daemon should be executable" "[ -x ${BUILD_DIR}/local/bin/newrelic-daemon ]" + + assertCaptured "-----> Copying config files" + assertTrue "php-fpm.conf exists and readable" "[ -r ${BUILD_DIR}/vendor/php/etc/php-fpm.conf ]" + assertTrue "php.ini exists and readable" "[ -r ${BUILD_DIR}/vendor/php/php.ini ]" + assertTrue "php/etc.d/ directory exists" "[ -d ${BUILD_DIR}/vendor/php/etc.d/ ]" + assertTrue "nginx.conf.erb exists and readable" "[ -r ${BUILD_DIR}/vendor/nginx/conf/nginx.conf.erb ]" + + assertCaptured "-----> Installing boot script" + assertTrue "boot.sh exists and executable" "[ -x ${BUILD_DIR}/boot.sh ]" + + assertCaptured "-----> Done with compile" +} diff --git a/test/detect_test.sh b/test/detect_test.sh new file mode 100644 index 000000000..ff0e8a1a1 --- /dev/null +++ b/test/detect_test.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh + +testDetect() +{ + mkdir -p ${BUILD_DIR}/ + touch ${BUILD_DIR}/index.php + + detect + + assertCapturedSuccess + assertAppDetected "PHP" +} + +testNoDetectPHP() +{ + mkdir -p ${BUILD_DIR}/ + + detect + + assertCapturedError 1 "no" + assertNoAppDetected +}