Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

added laravel 10, php 8.2, phpunit 10 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/phpunit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.1, 8.0 ]
php: [ 8.2, 8.1]
os: [ ubuntu-latest, windows-latest ]
dependency-version: [ prefer-lowest, prefer-stable ]

Expand Down Expand Up @@ -36,4 +36,4 @@ jobs:
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Execute tests (Unit and Feature tests) via PHPUnit 🧪
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If a password is found to be pwned, it will fail validation and the user will be
Install the package using Composer:

```bash
composer require assisted-mindfulness/pwned-validator/pwned-validator
composer require assisted-mindfulness/pwned-validator
```

Add the validation message to your validation lang file `lang/en/validation.php` :
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
}
},
"require": {
"php": "^8.0",
"laravel/framework": "^9.0",
"php": "^8.1",
"laravel/framework": "^10.0",
"guzzlehttp/guzzle": "^7.5"
},
"require-dev": {
"laravel/pint": "^1.2",
"vimeo/psalm": "^4.3 || ^5.0",
"phpunit/phpunit": "^9.0",
"orchestra/testbench-core": "^7.0"
"phpunit/phpunit": "^10.0",
"orchestra/testbench-core": "^8.0"
},
"extra": {
"laravel": {
Expand Down
66 changes: 21 additions & 45 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnError="false"
defaultTestSuite="Main"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".blade.php">./src/</directory>
</exclude>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Main">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_NAME" value="Pwned"/>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="APP_DEBUG" value="true"/>
<env name="APP_URL" value="http://127.0.0.1:8001"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="file"/>
<env name="SESSION_DRIVER" value="file"/>
<env name="SESSION_LIFETIME" value="120"/>
<env name="SCOUT_DRIVER" value="array"/>
<env name="SCOUT_QUEUE" value="true"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
<logging/>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" stopOnError="false" defaultTestSuite="Main" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Main">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_NAME" value="Pwned"/>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="APP_DEBUG" value="true"/>
<env name="APP_URL" value="http://127.0.0.1:8001"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="file"/>
<env name="SESSION_DRIVER" value="file"/>
<env name="SESSION_LIFETIME" value="120"/>
<env name="SCOUT_DRIVER" value="array"/>
<env name="SCOUT_QUEUE" value="true"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
<logging/>
</phpunit>
3 changes: 2 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"on_multiline": "ignore"
},
"trim_array_spaces": true,
"single_trait_insert_per_statement": false
"single_trait_insert_per_statement": false,
"no_superfluous_phpdoc_tags": false
}
}
10 changes: 10 additions & 0 deletions src/PwnedRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class PwnedRule implements Rule
{
/** @var int */
private int $minimum;

/**
Expand Down Expand Up @@ -52,6 +53,11 @@ private function hashAndSplit(string $value): array
];
}

/**
* @param $prefix
*
* @return \Illuminate\Support\Collection
*/
private function queryApi($prefix): Collection
{
$response = Http::withHeaders(['Add-Padding' => 'true'])
Expand All @@ -75,6 +81,10 @@ private function queryApi($prefix): Collection

/**
* Cache results for a week, to avoid constant API calls for identical prefixes
*
* @param $prefix
*
* @return \Illuminate\Support\Collection
*/
private function query($prefix): Collection
{
Expand Down
2 changes: 2 additions & 0 deletions src/PwnedServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class PwnedServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/PwnedRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testEasyPasswordFail(string $password)
$this->assertFalse($this->rule->passes('test', $password));
}

public function complexPasswords(): array
public static function complexPasswords(): array
{
return [
['B#xhhg$OmH5jG|huZV4n'],
Expand All @@ -60,7 +60,7 @@ public function complexPasswords(): array
];
}

public function easyPasswords()
public static function easyPasswords()
{
return [
['123456'],
Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
{
/**
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageProviders($app): array
{
Expand Down