diff --git a/.env.travis b/.env.mysql.travis similarity index 100% rename from .env.travis rename to .env.mysql.travis diff --git a/.env.postgres.travis b/.env.postgres.travis new file mode 100644 index 00000000000..812fb38a7a9 --- /dev/null +++ b/.env.postgres.travis @@ -0,0 +1,15 @@ +APP_ENV=testing +APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg= +APP_URL=http://localhost:8000 + +DB_CONNECTION=pgsqltesting +DB_TEST_HOST=127.0.0.1 +DB_TEST_DATABASE=monica +DB_TEST_USERNAME=postgres +DB_TEST_PASSWORD= + +CACHE_DRIVER=array +SESSION_DRIVER=array +QUEUE_DRIVER=sync + +2FA_ENABLED=true diff --git a/.travis.yml b/.travis.yml index 7ffb56652bd..746f1719cdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,35 @@ language: php php: - 7.1 + - 7.2 services: - mysql + - postgresql + +env: + matrix: + - DB=mysql + - DB=postgres + global: +# - SAUCELABS=1 + +matrix: + include: + - php: 7.1 + env: + - DB=mysql + - SELENIUM=1 + - COVERAGE=1 + exclude: + - php: 7.1 + env: DB=mysql + - php: 7.2 + env: DB=postgres + allow_failures: + - php: 7.2 + - env: DB=postgres + fast_finish: true jdk: - oraclejdk8 @@ -14,47 +40,45 @@ git: depth: false addons: + postgresql: "9.6" chrome: stable # sauce_connect: # username: "asbiin" # jwt: # secure: "niuYhwCsFVUHS6DU3j0xi24habQOSqKpzo7qUlGmlx1x31wZNDrl+wfifeTVv6nnjoShyr4s6svn3ULl1K8tQMdyHJlO247WKMg/PSnaSUyll5+luuP5SLpV+USP8g9a7HAjU+jQO5uE/GXKDDQcD+o5dV6gv9stmc9u/np45kwgVx55bj013ll0M5qlyflJZFgp3b/M+bvqkvIFDPN2U7iFs0dkhqxBI+6qbTAN4aTtxPSPrsYdt9W8Re1suzy2/CJEEQ2xKE4zm7WQ2dg6BrpbaU2bdG6wWZUw2toA8iCyxFgbJUlXmAjPEQ5Wr+gWEQ9bLcwCIoHxUMIRbqY/SNzve7KnGXOUEF0yttyAv3aq9STA58Mr+H15zXdA5ZAwpE/tNojfaacEya/bg9fwUWOCqrPXIhwFirhf8oD2y8n+SWD27rP0qD9um9HGqGkh6bqFefIZi2xVzLya1r/2kxqFskrj+0xPjjKYwMwJIM5s7HyrtIxR7QTpFEbgHpZjCmT31I65ds56ec34wbZ0W61bm4aQAxz7UIedCYsTrqtTzTYxUJEht3/1D5FH0PSBWQACJmdjSHvh0pP7zzG2cqzq2IhHCSZjnhh6LGUPQtgZh3kq1fSP0Zw74iSVrxQETsGoPwYA6R38e+V39vV8yUHjMUXNPIhgcQQZHiZcEWI=" -env: - global: -# - SAUCELABS=1 - before_script: - - cp .env.travis .env - mkdir -p $TRAVIS_BUILD_DIR/results/coverage - - mysql -e 'create database monica;' + - cp .env.$DB.travis .env + - if [[ "$DB" == "mysql" ]]; then mysql -v -e 'CREATE DATABASE monica;'; fi + - if [[ "$DB" == "postgres" ]]; then psql -e -c 'CREATE DATABASE monica;' -U postgres; fi - composer self-update - travis_retry composer install --no-interaction --prefer-dist --no-suggest - - if [ ! "$SAUCELABS" = "1" ]; then .ci/start-selenium.sh; fi + - if [[ "$SELENIUM" == "1" && ! "$SAUCELABS" == "1" ]]; then .ci/start-selenium.sh; fi script: - php artisan migrate --env=testing --no-interaction -vvv - php artisan db:seed --env=testing --no-interaction -vvv # Run unit tests - - vendor/bin/phpunit + - vendor/bin/phpunit -c phpunit${DB/mysql/}.xml # Start http server - - php -S 127.0.0.1:8000 -t $TRAVIS_BUILD_DIR/public $TRAVIS_BUILD_DIR/.ci/server-cc.php & - - until $(nc -z localhost 8000); do sleep 1; echo Waiting for laravel server to start...; done; + - bash -c "if [[ \"$SELENIUM\" == \"1\" ]]; then php -S 127.0.0.1:8000 -t $TRAVIS_BUILD_DIR/public $TRAVIS_BUILD_DIR/.ci/server-cc.php; fi" & + - if [[ "$SELENIUM" == "1" ]]; then until $(nc -z localhost 8000); do sleep 1; echo Waiting for laravel server to start...; done; fi # Run browser tests - - if [ "$SAUCELABS" = "1" ]; then vendor/bin/steward run travis chrome -vvv --server-url=http://$SAUCE_USERNAME:$SAUCE_ACCESS_KEY@localhost:4445 --capability="tunnel-identifier:'${TRAVIS_JOB_NUMBER}'"; fi - - if [ ! "$SAUCELABS" = "1" ]; then vendor/bin/steward run travis chrome -vvv; fi + - if [[ "$SELENIUM" == "1" && "$SAUCELABS" = "1" ]]; then vendor/bin/steward run travis chrome -vvv --server-url=http://$SAUCE_USERNAME:$SAUCE_ACCESS_KEY@localhost:4445 --capability="tunnel-identifier:'${TRAVIS_JOB_NUMBER}'"; fi + - if [[ "$SELENIUM" == "1" && ! "$SAUCELABS" = "1" ]]; then vendor/bin/steward run travis chrome -vvv; fi after_script: - - vendor/bin/steward results -vvv - - .ci/travis-report.sh 2>/dev/null - - cat selenium-server.log - - cat selenium-node.log - - vendor/bin/phpcov merge --clover=$TRAVIS_BUILD_DIR/results/coverage2.xml $TRAVIS_BUILD_DIR/results/coverage/ - - bash <(curl -s https://codecov.io/bash) - - ./travis-sonar.sh + - if [[ "$SELENIUM" == "1" ]]; then vendor/bin/steward results -vvv; fi + - if [[ "$SELENIUM" == "1" ]]; then .ci/travis-report.sh 2>/dev/null; fi + - if [[ "$SELENIUM" == "1" ]]; then cat selenium-server.log; fi + - if [[ "$SELENIUM" == "1" ]]; then cat selenium-node.log; fi + - if [[ "$COVERAGE" == "1" ]]; then vendor/bin/phpcov merge --clover=$TRAVIS_BUILD_DIR/results/coverage2.xml $TRAVIS_BUILD_DIR/results/coverage/; fi + - if [[ "$COVERAGE" == "1" ]]; then bash <(curl -s https://codecov.io/bash); fi + - if [[ "$COVERAGE" == "1" ]]; then ./travis-sonar.sh; fi cache: directories: diff --git a/.travis.yml.sig b/.travis.yml.sig index fc7a99b18db..6dbf79af0a6 100644 Binary files a/.travis.yml.sig and b/.travis.yml.sig differ diff --git a/config/database.php b/config/database.php index 48f0723c15a..6a46273d3d1 100644 --- a/config/database.php +++ b/config/database.php @@ -67,15 +67,15 @@ ], 'testing' => [ - 'driver' => 'mysql', - 'host' => env('DB_TEST_HOST'), - 'database' => env('DB_TEST_DATABASE'), - 'username' => env('DB_TEST_USERNAME'), - 'password' => env('DB_TEST_PASSWORD'), - 'charset' => 'utf8', + 'driver' => 'mysql', + 'host' => env('DB_TEST_HOST'), + 'database' => env('DB_TEST_DATABASE'), + 'username' => env('DB_TEST_USERNAME'), + 'password' => env('DB_TEST_PASSWORD'), + 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - 'strict' => false, + 'prefix' => '', + 'strict' => false, ], 'pgsql' => [ @@ -90,6 +90,19 @@ 'schema' => 'public', ], + 'pgsqltesting' => [ + 'driver' => 'pgsql', + 'host' => env('DB_TEST_HOST'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_TEST_DATABASE'), + 'username' => env('DB_TEST_USERNAME'), + 'password' => env('DB_TEST_PASSWORD'), + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + 'schema' => 'public', + ], + ], /* diff --git a/database/migrations/2017_10_14_083556_change_gift_column_structure.php b/database/migrations/2017_10_14_083556_change_gift_column_structure.php index 07beae3c291..9faa4e67eb1 100644 --- a/database/migrations/2017_10_14_083556_change_gift_column_structure.php +++ b/database/migrations/2017_10_14_083556_change_gift_column_structure.php @@ -13,7 +13,9 @@ class ChangeGiftColumnStructure extends Migration */ public function up() { - DB::statement('ALTER TABLE gifts MODIFY about_object_id INTEGER;'); + Schema::table('gifts', function (Blueprint $table) { + $table->integer('about_object_id')->change(); + }); Schema::table('gifts', function ($table) { $table->dropColumn([ diff --git a/database/migrations/2017_11_10_204035_delete_contact_fields_from_contacts.php b/database/migrations/2017_11_10_204035_delete_contact_fields_from_contacts.php index e3edf2da02f..c761df00ebf 100644 --- a/database/migrations/2017_11_10_204035_delete_contact_fields_from_contacts.php +++ b/database/migrations/2017_11_10_204035_delete_contact_fields_from_contacts.php @@ -14,7 +14,7 @@ class DeleteContactFieldsFromContacts extends Migration public function up() { Schema::table('contacts', function (Blueprint $table) { - $table->dropIndex('unique_for_each_account_email_pair'); + $table->dropUnique('unique_for_each_account_email_pair'); $table->dropColumn('email'); $table->dropColumn('phone_number'); $table->dropColumn('street'); diff --git a/phpunitpostgres.xml b/phpunitpostgres.xml new file mode 100644 index 00000000000..a1200b801dd --- /dev/null +++ b/phpunitpostgres.xml @@ -0,0 +1,53 @@ + + + + + ./tests/Unit + + + + ./tests/Helper + + + + ./tests/Feature + + + + ./tests/Api + + + + + ./app + + ./app/Http/routes.php + + + + + + + + + + + + + + + + + + + +