Skip to content

Instantly share code, notes, and snippets.

@drbyte
Created August 17, 2015 01:01
Show Gist options
  • Select an option

  • Save drbyte/05cd4e98608ca7c64161 to your computer and use it in GitHub Desktop.

Select an option

Save drbyte/05cd4e98608ca7c64161 to your computer and use it in GitHub Desktop.
Laravel Behat "Prep" script
#!/bin/bash
Echo 'Adding the HTML/Form helper'
composer require Illuminate/Html
echo 'Adding IDE Helper for PHPStorm/SublimeText'
composer require barryvdh/laravel-ide-helper --dev
php artisan ide-helper:generate
php artisan ide-helper:meta
echo 'Adding PHPSpec, Behat, Behat Mink, Laracasts Behat Extension'
composer require phpspec/phpspec behat/behat behat/mink behat/mink-extension laracasts/behat-laravel-extension --dev
#init behat
behat --init
# add mink and databasetransactions and phpunit support
sed -i '' "s/class FeatureContext implements/class FeatureContext extends Behat\\\MinkExtension\\\Context\\\MinkContext implements/" features/bootstrap/FeatureContext.php
sed -i '' '/use Behat\\\Behat\\\Context\\\Context;/a\'$'\n''use Behat\\\MinkExtension\\\Context\\\MinkContext;\'$'\n''use Laracasts\\\Behat\\\Context\\\DatabaseTransactions;\'$'\n''use PHPUnit_Framework_Assert as PHPUnit;'$'\n' features/bootstrap/FeatureContext.php
# create default behat.yml
printf "default:\n extensions:\n Laracasts\Behat:\n # env_path: .env.behat\n Behat\MinkExtension:\n default_session: laravel\n base_url: http://localhost:8888\n laravel: ~\n\n#to enable the server manually, you may need to run:\n#php -S localhost:8888 -t public\n" | tee -a behat.yml
# create the .env.behat file
cp .env .env.behat
# set APP_ENV to 'testing' for behat
sed -i '' "s/APP_ENV=.*/APP_ENV=testing/" .env.behat
# set the spec path for phpspec
echo "\n spec_path: tests" >> phpspec.yml
echo 'Done.'
echo 'Be sure to add the ServiceProviders to config/app.php for the packages installed:'
echo ' Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,'
echo ' Illuminate\Html\HtmlServiceProvider::class,'
echo ''
echo ' and the Facades:'
echo " 'Html' => Illuminate\Html\HtmlFacade::class,"
echo " 'Form' => Illuminate\Html\FormFacade::class,"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment