From 5c360bb960923d461cf41f42ab4170c6ec5e7c7f Mon Sep 17 00:00:00 2001 From: emincanozcan <50255411+emincanozcan@users.noreply.github.com> Date: Sun, 12 Dec 2021 11:02:23 +0300 Subject: [PATCH] Update tests & add github workflow to run tests --- .github/workflows/run-tests.yml | 41 ++++++++++++++++++++++++++++++ database/factories/UserFactory.php | 1 + tests/Feature/RegistrationTest.php | 1 + 3 files changed, 43 insertions(+) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..487c225 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,41 @@ +name: run-tests + +on: [push, pull_request] + +jobs: + test: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ["8.1", "8.0"] + laravel: ["^8.0"] + dependency-version: [prefer-lowest, prefer-stable] + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" --dev --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 8705898..3f1a060 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -26,6 +26,7 @@ public function definition() { return [ 'name' => $this->faker->name(), + 'username' => $this->faker->userName(), 'email' => $this->faker->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password diff --git a/tests/Feature/RegistrationTest.php b/tests/Feature/RegistrationTest.php index aae144f..c0c9d5c 100644 --- a/tests/Feature/RegistrationTest.php +++ b/tests/Feature/RegistrationTest.php @@ -42,6 +42,7 @@ public function test_new_users_can_register() $response = $this->post('/register', [ 'name' => 'Test User', + 'username' => 'iComposeArtLikeTheGhostOfMozart', 'email' => 'test@example.com', 'password' => 'password', 'password_confirmation' => 'password',