Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ core.autocrlf=lf
.php_cs export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
Makefile export-ignore
.github export-ignore
phpunit.xml.dist export-ignore
/tests export-ignore
Expand Down
97 changes: 97 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Full CI process
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
name: PHP ${{ matrix.php-versions }}
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
include:
- PHP_VERSION: '7.1'
SYMFONY_REQUIRE: '^3.4'
- PHP_VERSION: '7.2'
SYMFONY_REQUIRE: '^4.4'
- PHP_VERSION: '7.3'
SYMFONY_REQUIRE: '^5.0'
- PHP_VERSION: '7.4'

steps:
# —— Setup Github actions 🐙 —————————————————————————————————————————————
# https://github.com/actions/checkout (official)
-
name: Checkout
uses: actions/checkout@v2

# https://github.com/shivammathur/setup-php (community)
-
name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.PHP_VERSION }}
extensions: mbstring, ctype, iconv, bcmath, filter, json
coverage: none
env:
update: true

# —— Composer 🧙‍️ —————————————————————————————————————————————————————————
-
name: Install Composer dependencies
env:
SYMFONY_REQUIRE: ${{ matrix.SYMFONY_REQUIRE }}
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: 1
SYMFONY_PHPUNIT_REMOVE: "symfony/yaml"
SYMFONY_PHPUNIT_VERSION: '7.5.6'
run: |
git config --global author.name Sebastiaan Stok
git config --global author.email [email protected]
git config --global user.name Sebastiaan Stok
git config --global user.email [email protected]

rm -f composer.lock
composer global require symfony/flex
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi

## —— Tests ✅ ———————————————————————————————————————————————————————————
-
name: Run Tests
run: |
make test
lint:
name: PHP-QA
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
-
name: Checkout
uses: actions/checkout@v2

# https://github.com/shivammathur/setup-php (community)
-
name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, ctype, iconv, bcmath, filter, json
coverage: none

# —— Composer 🧙‍️ —————————————————————————————————————————————————————————
-
name: Install Composer dependencies
run: |
rm -f composer.lock
composer global require symfony/flex
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi

-
name: Run PHP-QA
run: |
make cs-full
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/vendor/
/.php_cs.cache
symfony.lock
.phpunit.result.cache
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
QA_DOCKER_IMAGE=jakzal/phpqa:1.34.1-php7.4-alpine
QA_DOCKER_COMMAND=docker run --init -t --rm --user "$(shell id -u):$(shell id -g)" --volume /tmp/tmp-phpqa-$(shell id -u):/tmp --volume "$(shell pwd):/project" --workdir /project ${QA_DOCKER_IMAGE}

dist: install cs-full phpstan test-full
lint: install security-check cs-full phpstan

install:
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --prefer-dist --ansi

test:
./vendor/bin/simple-phpunit --verbose

# Linting tools
security-check: ensure
sh -c "${QA_DOCKER_COMMAND} security-checker security:check ./composer.lock"

phpstan: ensure
sh -c "${QA_DOCKER_COMMAND} phpstan analyse --configuration phpstan.neon"

cs: ensure
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --diff"

cs-full: ensure
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff"

cs-full-check: ensure
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff --dry-run"

ensure:
mkdir -p ${HOME}/.composer /tmp/tmp-phpqa-$(shell id -u)

.PHONY: install test phpstan cs cs-full cs-full-check
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
"symfony/validator": "^3.4.22 || ^4.0 || ^5.0"
},
"require-dev": {
"guzzlehttp/psr7": "^1.4",
"php-http/httplug": "^1.1",
"phpspec/prophecy": "^1.10.3",
"symfony/config": "^3.4.22 || ^4.0 || ^5.0",
"symfony/console": "^3.4.22 || ^4.0 || ^5.0",
"symfony/phpunit-bridge": "^3.4.22 || ^4.0 || ^5.0",
"php-http/httplug": "^1.1",
"guzzlehttp/psr7": "^1.4"
"symfony/phpunit-bridge": "^4.4 || ^5.0"
},
"autoload": {
"psr-4": {
Expand All @@ -42,10 +43,7 @@
"autoload-dev": {
"psr-4": {
"Rollerworks\\Component\\PasswordStrength\\Tests\\": "tests/"
},
"files": [
"tests/Symfony27Compat.php"
]
}
},
"extra": {
"branch-alias": {
Expand Down
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ includes:
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
autoload_files:
- vendor/autoload.php
- vendor/bin/.phpunit/phpunit-7.5.6-0/vendor/autoload.php # Pain is your friend.... (at least it works for now)
level: 5
paths:
- ./src
- ./tests

ignoreErrors:
#- '#__construct\(\) does not call parent constructor from .+#'
Expand Down
9 changes: 6 additions & 3 deletions tests/Blacklist/SqliteProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

use PHPUnit\Framework\TestCase;
use Rollerworks\Component\PasswordStrength\Blacklist\SqliteProvider;
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;

class SqliteProviderTest extends TestCase
{
use SetUpTearDownTrait;

/**
* @var string
*/
Expand All @@ -26,7 +29,7 @@ class SqliteProviderTest extends TestCase
*/
protected static $provider;

public static function setUpBeforeClass()
public static function doSetUpBeforeClass()
{
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
self::markTestSkipped('This test requires SQLite support in your environment');
Expand All @@ -40,7 +43,7 @@ public static function setUpBeforeClass()
self::$provider = new SqliteProvider('sqlite:'.self::$dbFile);
}

public static function tearDownAfterClass()
public static function doTearDownAfterClass()
{
@unlink(self::$dbFile);
}
Expand Down Expand Up @@ -84,7 +87,7 @@ public function testPurge()
self::assertTrue(self::$provider->isBlacklisted('test'));
}

protected function setUp()
protected function doSetUp()
{
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
$this->markTestSkipped('This test requires SQLite support in your environment');
Expand Down
8 changes: 5 additions & 3 deletions tests/Command/BlacklistCommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
use PHPUnit\Framework\TestCase;
use Rollerworks\Component\PasswordStrength\Blacklist\SqliteProvider;
use Rollerworks\Component\PasswordStrength\Tests\BlackListMockProviderTrait;
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;

abstract class BlacklistCommandTestCase extends TestCase
{
use BlackListMockProviderTrait;
use SetUpTearDownTrait;

protected static $dbFile;
protected static $storage;
Expand All @@ -27,7 +29,7 @@ abstract class BlacklistCommandTestCase extends TestCase
*/
protected static $blackListProvider;

public static function setUpBeforeClass()
public static function doSetUpBeforeClass()
{
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
self::markTestSkipped('This test requires SQLite support in your environment');
Expand All @@ -41,12 +43,12 @@ public static function setUpBeforeClass()
self::$blackListProvider = new SqliteProvider('sqlite:'.self::$dbFile);
}

public static function tearDownAfterClass()
public static function doTearDownAfterClass()
{
@unlink(self::$dbFile);
}

protected function setUp()
protected function doSetUp()
{
self::$blackListProvider->purge();
}
Expand Down
5 changes: 4 additions & 1 deletion tests/P0wnedPassword/Request/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
use Psr\Log\NullLogger;
use Rollerworks\Component\PasswordStrength\P0wnedPassword\Request\Client;
use Rollerworks\Component\PasswordStrength\P0wnedPassword\Request\Result;
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;

class ClientTest extends TestCase
{
use SetUpTearDownTrait;

/** @var HttpClient|MockObject */
private $client;

Expand Down Expand Up @@ -56,7 +59,7 @@ class ClientTest extends TestCase
0C341F894BD4EE961AE874ACD3BC8157825:4
';

public function setUp()
public function doSetUp()
{
$this->client = $this->createMock(HttpClient::class);
$this->checker = new Client($this->client, new NullLogger());
Expand Down
17 changes: 0 additions & 17 deletions tests/Symfony27Compat.php

This file was deleted.

6 changes: 3 additions & 3 deletions tests/Validator/BlacklistValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Rollerworks\Component\PasswordStrength\Validator\Constraints\Blacklist;
use Rollerworks\Component\PasswordStrength\Validator\Constraints\BlacklistValidator;
use Symfony\Component\Validator\Exception\RuntimeException;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class BlacklistValidationTest extends ConstraintValidatorTestCase
Expand Down Expand Up @@ -63,11 +64,10 @@ public function testEmptyStringIsValid()
$this->assertNoViolation();
}

/**
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
*/
public function testExpectsStringCompatibleType()
{
$this->expectException(UnexpectedTypeException::class);

$this->validator->validate(new \stdClass(), new Blacklist());
}

Expand Down
Loading