diff --git a/.gitattributes b/.gitattributes index 7e67641..72d093f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,6 @@ -/tests export-ignore -.gitattributes export-ignore -.gitignore export-ignore -.travis.yml export-ignore -phpunit.xml.dist export-ignore +/.gitattributes export-ignore +/.github/ export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/tests/ export-ignore diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ae992e3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f37f558 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: test + +on: + push: + pull_request: + +jobs: + linux_tests: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + stability: [prefer-stable] + + name: PHP ${{ matrix.php }} - ${{ matrix.stability }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: error_reporting=E_ALL + tools: composer:v2 + coverage: xdebug + + - name: Install dependencies + run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress + + - name: Execute tests + run: php vendor/bin/phpunit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e965357..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - - 7.4 - - 8.0snapshot - -before_script: - - travis_retry composer self-update - - travis_retry composer install --no-interaction --prefer-source - -script: - - vendor/bin/phpunit diff --git a/composer.json b/composer.json index ff26023..1a5a2bf 100644 --- a/composer.json +++ b/composer.json @@ -20,12 +20,12 @@ ], "require": { "php": ">=7.2", - "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0" + "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0" }, "require-dev": { - "phpunit/phpunit": "^8.0|^9.0", - "orchestra/testbench": "^5.0|^6.0", - "doctrine/dbal": "^2.9" + "phpunit/phpunit": "^8.0|^9.0|^10.0|^11.0|^12.0", + "orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0", + "doctrine/dbal": "^2.9|^3.0|^4.0" }, "autoload": { "psr-4": { diff --git a/tests/MigrationTest.php b/tests/MigrationTest.php index 7b9dc72..fb31c52 100644 --- a/tests/MigrationTest.php +++ b/tests/MigrationTest.php @@ -2,15 +2,14 @@ use Illuminate\Support\Facades\Schema; -class MigrationsTest extends TestCase +class MigrationTest extends TestCase { /* ------------------------------------------------------------------------------------------------ | Test Functions | ------------------------------------------------------------------------------------------------ */ - /** @test */ - public function itCanMigrate() + public function testItCanMigrate() { $this->migrate(); diff --git a/tests/Models/ModelsTest.php b/tests/Models/ModelsTestCase.php similarity index 91% rename from tests/Models/ModelsTest.php rename to tests/Models/ModelsTestCase.php index 2f52c62..a16193c 100644 --- a/tests/Models/ModelsTest.php +++ b/tests/Models/ModelsTestCase.php @@ -2,7 +2,7 @@ use Kodeine\Acl\Tests\TestCase; -abstract class ModelsTest extends TestCase +abstract class ModelsTestCase extends TestCase { /* ------------------------------------------------------------------------------------------------ | Main Functions diff --git a/tests/Models/PermissionTest.php b/tests/Models/PermissionTest.php index 386f888..e1e937f 100644 --- a/tests/Models/PermissionTest.php +++ b/tests/Models/PermissionTest.php @@ -4,7 +4,7 @@ use Kodeine\Acl\Models\Eloquent\Role; use Illuminate\Database\Eloquent\Relations\BelongsToMany; -class PermissionTest extends ModelsTest +class PermissionTest extends ModelsTestCase { /* ------------------------------------------------------------------------------------------------ | Properties @@ -37,8 +37,7 @@ public function tearDown(): void | Test Functions | ------------------------------------------------------------------------------------------------ */ - /** @test */ - public function itCanBeInstantiated() + public function testItCanBeInstantiated() { $expectations = [ \Illuminate\Database\Eloquent\Model::class, @@ -50,8 +49,7 @@ public function itCanBeInstantiated() } } - /** @test */ - public function itHasRelationships() + public function testItHasRelationships() { $rolesRelationship = $this->permissionModel->roles(); @@ -63,8 +61,7 @@ public function itHasRelationships() ); } - /** @test */ - public function itCanCreate() + public function testItCanCreate() { $attributes = [ 'name' => 'Create users', @@ -84,8 +81,7 @@ public function itCanCreate() ]); } - /** @test */ - public function itCanUpdate() + public function testItCanUpdate() { $attributes = [ 'name' => 'Create users', @@ -114,8 +110,7 @@ public function itCanUpdate() $this->assertDatabaseMissing('permissions', $attributes); } - /** @test */ - public function itCanDelete() + public function testItCanDelete() { $attributes = [ 'name' => 'Create users', diff --git a/tests/Models/RoleTest.php b/tests/Models/RoleTest.php index a26b623..54ec808 100644 --- a/tests/Models/RoleTest.php +++ b/tests/Models/RoleTest.php @@ -5,7 +5,7 @@ use Kodeine\Acl\Models\Eloquent\User; use Illuminate\Database\Eloquent\Relations\BelongsToMany; -class RoleTest extends ModelsTest +class RoleTest extends ModelsTestCase { /* ------------------------------------------------------------------------------------------------ | Properties @@ -36,8 +36,7 @@ public function tearDown(): void | Test Functions | ------------------------------------------------------------------------------------------------ */ - /** @test */ - public function itCanBeInstantiated() + public function testItCanBeInstantiated() { $expectations = [ \Illuminate\Database\Eloquent\Model::class, @@ -49,8 +48,7 @@ public function itCanBeInstantiated() } } - /** @test */ - public function itHasRelationships() + public function testItHasRelationships() { $usersRelationship = $this->roleModel->users(); $permissionsRelationship = $this->roleModel->permissions(); @@ -68,9 +66,8 @@ public function itHasRelationships() $this->assertInstanceOf(User::class, $user); $this->assertInstanceOf(Permission::class, $permission); } - - /** @test */ - public function itCanCreate() + + public function testItCanCreate() { $attributes = [ 'name' => 'Custom role', @@ -86,9 +83,8 @@ public function itCanCreate() $this->assertDatabaseHas('roles', $attributes); } - - /** @test */ - public function itCanUpdate() + + public function testItCanUpdate() { $attributes = $this->getAdminRoleAttributes(); @@ -108,9 +104,8 @@ public function itCanUpdate() $this->assertDatabaseHas('roles', $updatedAttributes); $this->assertDatabaseHas('roles', $role->toArray()); } - - /** @test */ - public function itCanDelete() + + public function testItCanDelete() { $role = $this->createRole(); diff --git a/tests/Models/UserTest.php b/tests/Models/UserTest.php index 42942e5..5409223 100644 --- a/tests/Models/UserTest.php +++ b/tests/Models/UserTest.php @@ -5,7 +5,7 @@ use Kodeine\Acl\Models\Eloquent\User; use Illuminate\Database\Eloquent\Relations\BelongsToMany; -class UserTest extends ModelsTest +class UserTest extends ModelsTestCase { /* ------------------------------------------------------------------------------------------------ | Properties @@ -36,8 +36,7 @@ public function tearDown(): void | Test Functions | ------------------------------------------------------------------------------------------------ */ - /** @test */ - public function itCanBeInstantiated() + public function testItCanBeInstantiated() { $expectations = [ \Illuminate\Database\Eloquent\Model::class, @@ -49,8 +48,7 @@ public function itCanBeInstantiated() } } - /** @test */ - public function itCanAttachRole() + public function testItCanAttachRole() { $objRole = new Role(); $role = $objRole->create([ @@ -70,8 +68,7 @@ public function itCanAttachRole() $this->assertEquals($user->getRoles(), [ 1 => $this->str_slug('Admin role', config('laravel-auth.slug-separator'))]); } - /** @test */ - public function itCanAttachRoleAndPermission() + public function testItCanAttachRoleAndPermission() { $objRole = new Role(); $roleAttributes = [ @@ -107,8 +104,7 @@ public function itCanAttachRoleAndPermission() $this->assertEquals($user->getPermissions(), ['post' => $permissionAttributes['slug']]); } - /** @test */ - public function cacheTest() + public function testCache() { $objRole = new Role(); $roleAttributes = [