diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..7397bfd --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,82 @@ +name: Tests + +on: + push: + branches: + - master + pull_request: + +jobs: + phpUnitTests: + runs-on: ubuntu-latest + name: Unit Tests / PHP ${{ matrix.phpVersions }} + strategy: + max-parallel: 6 + matrix: + phpVersions: ['7.2', '7.3', '7.4'] + fail-fast: false + env: + phpExtensions: mbstring, intl, gd, xml, sqlite + cacheKey: ext-cache-v1 + octoberCmsRelease: develop + steps: + - name: Checkout changes + uses: actions/checkout@v2 + with: + path: user-plugin + + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.phpVersions }} + extensions: ${{ env.phpExtensions }} + key: ${{ env.cacheKey }} + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + + - name: Install PHP and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.phpVersions }} + extensions: ${{ env.phpExtensions }} + tools: composer + coverage: none + + - name: Install October CMS + run: | + wget https://github.com/octobercms/october/archive/${{ env.octoberCmsRelease }}.zip + unzip ${{ env.octoberCmsRelease }}.zip + shopt -s dotglob + mv october-${{ env.octoberCmsRelease }}/* ./ + shopt -u dotglob + cp config/cms.php config/testing/cms.php + mkdir -p plugins/rainlab + mv user-plugin plugins/rainlab/user + + - name: Get Composer cache directory + id: composercache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-interaction --no-progress --no-suggest + + - name: Run linting + run: ./vendor/bin/parallel-lint plugins/rainlab/user + + - name: Run unit tests + run: | + cd plugins/rainlab/user + ../../../vendor/bin/phpunit \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a8cd5f3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: php - -php: - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - nightly - -matrix: - allow_failures: - - php: nightly - -before_script: - - wget https://getcomposer.org/composer.phar - - php composer.phar install --no-interaction - - composer self-update - - git clone https://github.com/octobercms/october.git - - mkdir -p ./october/plugins/rainlab/user - - mv !(october) october/plugins/rainlab/user - - cd october - - composer install - - cp config/cms.php config/testing/cms.php - - cd ./plugins/rainlab/user - -script: - - php vendor/bin/phpunit diff --git a/composer.json b/composer.json index cd4d72c..0b4f218 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,5 @@ "php": ">=5.5.9", "composer/installers": "~1.0" }, - "require-dev": { - "phpunit/phpunit": "~5.7" - }, "minimum-stability": "dev" } diff --git a/tests/PluginTestCase.php b/tests/PluginTestCase.php index d003852..d14dc81 100644 --- a/tests/PluginTestCase.php +++ b/tests/PluginTestCase.php @@ -1,9 +1,8 @@ alias('Auth', 'RainLab\User\Facades\Auth'); - App::singleton('user.auth', function() { + App::singleton('user.auth', function () { return \RainLab\User\Classes\AuthManager::instance(); }); } diff --git a/tests/unit/facades/AuthFacadeTest.php b/tests/unit/facades/AuthFacadeTest.php index 0707254..62299b6 100644 --- a/tests/unit/facades/AuthFacadeTest.php +++ b/tests/unit/facades/AuthFacadeTest.php @@ -6,7 +6,7 @@ class AuthFacadeTest extends PluginTestCase { - public function test_registering_a_user() + public function testRegisteringAUser() { // register a user $user = Auth::register([ @@ -26,7 +26,7 @@ public function test_registering_a_user() $this->assertEquals('some@website.tld', $user->email); } - public function test_registering_a_user_with_auto_activation() + public function testRegisteringAUserWithAutoActivation() { // register a user with the auto-activate flag $user = Auth::register([ @@ -43,7 +43,7 @@ public function test_registering_a_user_with_auto_activation() $this->assertTrue(Auth::check()); } - public function test_registering_a_guest() + public function testRegisteringAGuest() { // register a guest $guest = Auth::registerGuest(['email' => 'person@acme.tld']); @@ -57,7 +57,7 @@ public function test_registering_a_guest() $this->assertEquals('person@acme.tld', $guest->email); } - public function test_login_and_checking_authentication() + public function testLoginAndCheckingAuthentication() { // we should not be authenticated $this->assertFalse(Auth::check());