瀏覽代碼

Merge pull request #236 from andreapollastri/master

Pipeline in branch
Andrea Pollastri 4 年之前
父節點
當前提交
db2dcf16c0
共有 4 個文件被更改,包括 73 次插入21 次删除
  1. 35 0
      .github/workflows/laravel.yml
  2. 1 0
      composer.json
  3. 37 0
      tests/Feature/CipiTest.php
  4. 0 21
      tests/Feature/ExampleTest.php

+ 35 - 0
.github/workflows/laravel.yml

@@ -0,0 +1,35 @@
+name: Laravel
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  laravel-tests:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
+      with:
+        php-version: '8.0'
+    - uses: actions/checkout@v2
+    - name: Copy .env
+      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
+    - name: Install Dependencies
+      run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
+    - name: Generate key
+      run: php artisan key:generate
+    - name: Directory Permissions
+      run: chmod -R 777 storage bootstrap/cache
+    - name: Create Database
+      run: |
+        mkdir -p database
+        touch database/database.sqlite
+    - name: Execute tests (Unit and Feature tests) via PHPUnit
+      env:
+        DB_CONNECTION: sqlite
+        DB_DATABASE: database/database.sqlite
+      run: vendor/bin/phpunit

+ 1 - 0
composer.json

@@ -15,6 +15,7 @@
         "firebase/php-jwt": "^5.2",
         "fruitcake/laravel-cors": "^2.0",
         "guzzlehttp/guzzle": "^7.0.1",
+        "laravel/browser-kit-testing": "^6.2",
         "laravel/framework": "^8.12",
         "laravel/tinker": "^2.5",
         "phpseclib/phpseclib": "^3.0"

+ 37 - 0
tests/Feature/CipiTest.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace Tests\Feature;
+
+use Illuminate\Foundation\Testing\WithoutMiddleware;
+use Illuminate\Foundation\Testing\DatabaseTransactions;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Tests\TestCase;
+
+class CipiTest extends TestCase
+{
+  
+    public function testRedirectToDashboard()
+    {
+        $response = $this->get('/');
+        $response->assertRedirect('/dashboard');
+    }
+
+    public function testShowLoginPage()
+    {
+        $response = $this->get('/login');
+        $response->assertSee('Cipi Control Panel');
+        $response->assertStatus(200);
+    }
+  
+    /*
+    public function testDefaultLogin()
+    {
+        $this->visit('/login')
+             ->type('administrator', 'username')
+             ->type('12345678', 'password')
+             ->press('OK')
+             ->seePageIs('/dashboard');
+    }
+    */
+
+}

+ 0 - 21
tests/Feature/ExampleTest.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace Tests\Feature;
-
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Tests\TestCase;
-
-class ExampleTest extends TestCase
-{
-    /**
-     * A basic test example.
-     *
-     * @return void
-     */
-    public function testBasicTest()
-    {
-        $response = $this->get('/');
-
-        $response->assertStatus(200);
-    }
-}