Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: php-casbin/codeigniter-permission
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.0
Choose a base ref
...
head repository: php-casbin/codeigniter-permission
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 8 commits
  • 13 files changed
  • 4 contributors

Commits on Mar 9, 2020

  1. Update README.md

    leeqvip committed Mar 9, 2020
    Copy the full SHA
    4023c6d View commit details

Commits on Apr 10, 2021

  1. feat: use 'Github Actions' to run tests and auto release

    feat: use 'Github Actions' to run tests and auto release
    basakest committed Apr 10, 2021
    Copy the full SHA
    18a77aa View commit details

Commits on Sep 20, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    832641f View commit details
  2. Update composer.json

    leeqvip authored Sep 20, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6078fad View commit details
  3. Merge pull request #2 from basakest/githubAction

    feat: use 'Github Actions' to run tests and auto release
    leeqvip authored Sep 20, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9a26e4e View commit details

Commits on Apr 20, 2024

  1. feat: upgrade casbin dependency to 3.21.6 (#5)

    * feat: upgrade casbin dependency to 3.21.6
    
    * fix: add phpunit 8.0
    
    * fix: add phpunit 9.0
    
    * ci: update nodejs to v4
    
    ---------
    
    Co-authored-by: Jon <techlee@qq.com>
    hsluoyz and leeqvip authored Apr 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d3c171a View commit details

Commits on Nov 29, 2024

  1. BREAKING CHANGE: upgrade to PHP 8.0 and PHP-Casbin 4.0 (#6)

    leeqvip authored Nov 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a50dcd6 View commit details

Commits on Dec 18, 2024

  1. ci: update workflows

    leeqvip committed Dec 18, 2024
    Copy the full SHA
    9da2f49 View commit details
Showing with 132 additions and 97 deletions.
  1. +2 −0 .github/semantic.yml
  2. +83 −0 .github/workflows/phpunit.yml
  3. +4 −0 .releaserc.yml
  4. +0 −24 .travis.yml
  5. +4 −4 README.md
  6. +5 −7 composer.json
  7. +18 −13 phpunit.xml.dist
  8. +2 −2 src/Config/Enforcer.php
  9. +1 −1 src/Config/Services.php
  10. +8 −2 src/EnforcerManager.php
  11. +0 −18 src/Logger.php
  12. +5 −2 tests/EnforcerManagerTest.php
  13. +0 −24 tests/travis/Database.php
2 changes: 2 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Always validate the PR title AND all the commits
titleAndCommits: true
83 changes: 83 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: PHPUnit

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: casbin
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: true
matrix:
php: [8.1, 8.2, 8.3]

name: PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: xdebug

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer install --prefer-dist --no-progress --no-suggest
- name: Run test suite
run: ./vendor/bin/phpunit

- name: Run Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: ${{ runner.os }} - ${{ matrix.php }}
run: |
composer global require php-coveralls/php-coveralls:^2.7
php-coveralls --coverage_clover=build/logs/clover.xml -v
upload-coverage:
runs-on: ubuntu-latest
needs: [ test ]
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

semantic-release:
runs-on: ubuntu-latest
needs: [ test, upload-coverage ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release
4 changes: 4 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/github"
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
</p>

<p align="center">
<a href="https://travis-ci.org/php-casbin/codeigniter-permission">
<img src="https://travis-ci.org/php-casbin/codeigniter-permission.svg?branch=master" alt="Build Status">
<a href="https://github.com/php-casbin/codeigniter-permission/actions/workflows/phpunit.yml">
<img src="https://github.com/php-casbin/codeigniter-permission/actions/workflows/phpunit.yml/badge.svg" alt="Build Status">
</a>
<a href="https://coveralls.io/github/php-casbin/codeigniter-permission">
<img src="https://coveralls.io/repos/github/php-casbin/codeigniter-permission/badge.svg" alt="Coverage Status">
@@ -39,10 +39,10 @@ All you need to learn to use `Casbin` first.

## Installation

Require this package in the `composer.json` of your CodeIgniter project. This will download the package.
Require this package in the `composer.json` of your `CodeIgniter 4` project. This will download the package.

```
composer require casbin/codeigniter-permission:dev-master
composer require casbin/codeigniter-permission
```

To migrate the migrations, run the migrate command:
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -22,23 +22,21 @@
"test": "vendor/bin/phpunit"
},
"require": {
"php": ">=7.2",
"codeigniter4/framework": "^4",
"casbin/casbin": "^2.0",
"casbin/psr3-bridge": "^1.1"
"php": "^8.1",
"codeigniter4/framework": "^4.5",
"casbin/casbin": "^4.0.2"
},
"autoload": {
"psr-4": {
"Casbin\\CodeIgniter\\": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"php-coveralls/php-coveralls": "^2.1"
"phpunit/phpunit": "^10.0|^11.0"
},
"autoload-dev": {
"psr-4": {
"Casbin\\CodeIgniter\\Tests\\": "tests/"
}
}
}
}
31 changes: 18 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/codeigniter4/framework/tests/_support/_bootstrap.php"
<phpunit bootstrap="vendor/codeigniter4/framework/system/Test/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
@@ -14,15 +11,23 @@
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-html" target="build/html"/>
</logging>

<coverage includeUncoveredFiles="true"
pathCoverage="false"
ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="true">
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/html" lowUpperBound="50" highLowerBound="90"/>
</report>
</coverage>

<source>
<include>
<directory>./src</directory>
</include>
</source>

<php>
<env name="app.baseURL" value="http://example.com"/>
<env name="database.tests.hostname" value="127.0.0.1"/>
4 changes: 2 additions & 2 deletions src/Config/Enforcer.php
Original file line number Diff line number Diff line change
@@ -47,8 +47,8 @@ class Enforcer extends BaseConfig
// changes whether Casbin will log messages to the Logger.
'enabled' => false,

// Casbin Logger
'logger' => \Casbin\CodeIgniter\Logger::class,
// Casbin Logger, Supported: \Psr\Log\LoggerInterface|string
'logger' => 'logger',
],

'cache' => [
2 changes: 1 addition & 1 deletion src/Config/Services.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ class Services extends BaseService
*
* @return \Casbin\CodeIgniter\EnforcerManager
*/
public static function enforcer(Enforcer $config = null, bool $getShared = true)
public static function enforcer(?Enforcer $config = null, bool $getShared = true)
{
if ($getShared) {
return static::getSharedInstance('enforcer', $config);
10 changes: 8 additions & 2 deletions src/EnforcerManager.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
use Casbin\Enforcer;
use Casbin\Model\Model;
use Casbin\Log\Log;
use Casbin\Log\Logger\DefaultLogger;
use Config\Services;
use InvalidArgumentException;
use Casbin\CodeIgniter\Config\Enforcer as EnforcerConfig;

@@ -75,7 +77,11 @@ protected function resolve($name)
}

if ($logger = $config['log']['logger']) {
Log::setLogger(new $logger());
if (is_string($logger)) {
$logger = new DefaultLogger(Services::$logger());
}

Log::setLogger($logger);
}

$model = new Model();
@@ -92,7 +98,7 @@ protected function resolve($name)
}
}

return new Enforcer($model, $adapter, $config['log']['enabled']);
return new Enforcer($model, $adapter, $logger, $config['log']['enabled']);
}

/**
18 changes: 0 additions & 18 deletions src/Logger.php

This file was deleted.

7 changes: 5 additions & 2 deletions tests/EnforcerManagerTest.php
Original file line number Diff line number Diff line change
@@ -2,14 +2,17 @@

namespace Casbin\CodeIgniter\Tests;

use CodeIgniter\Test\CIDatabaseTestCase;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use Config\Services
;
use Config\Autoload;
use Config\Modules;

class EnforcerManagerTest extends CIDatabaseTestCase
class EnforcerManagerTest extends CIUnitTestCase
{
use DatabaseTestTrait;

protected function createApplication()
{
$app = parent::createApplication();
24 changes: 0 additions & 24 deletions tests/travis/Database.php

This file was deleted.