Skip to content

Commit

Permalink
Update to Laravel 10 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdheiden authored Mar 23, 2023
1 parent 7fcacbf commit 997bd85
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 26 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
name: CSR generator

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
csr-generator-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.1']
php-versions: [ '8.1' ]

name: PHP ${{ matrix.php-versions }}

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress

- name: Execute tests (Unit and Feature tests) via PHPUnit
run: |
vendor/bin/phpunit
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: |
vendor/bin/phpunit
- name: Execute static analysis
run: |
vendor/bin/phpstan
- name: Execute static analysis
run: |
vendor/bin/phpstan
- name: Execute linter
run: |
vendor/bin/pint --test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ composer.lock
/.idea/
/build/
.phpunit.result.cache
.phpunit.cache

# macOS
.DS_Store
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
}
],
"require": {
"php": "^8.1",
"php": ">=8.1",
"ext-openssl": "*",
"laravel/framework": "^9.0",
"laravel/framework": "^9.0|^10.0",
"laravel/pint": "^1.7",
"spatie/laravel-package-tools": "^1.11"
},
"require-dev": {
"orchestra/testbench": "7.*",
"orchestra/testbench": "^7.0|^8.0",
"phpstan/phpstan": "^1.6",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^10.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">src/</directory>
Expand Down
7 changes: 7 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"preset": "laravel",
"rules": {
"array_indentation": false,
"Laravel/laravel_phpdoc_alignment": false
}
}
3 changes: 3 additions & 0 deletions src/CsrGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
class CsrGenerator
{
private string $digestAlg;

private SubjectFields $subjectFields;

private PrivateKey $privateKey;

/** @var array<string, string> */
private array $additionalOptions = [];

Expand Down
1 change: 1 addition & 0 deletions src/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class PrivateKey implements Stringable
{
private string $passPhrase = '';

/** @var array<string, string> */
private array $additionalOptions = [];

Expand Down
5 changes: 4 additions & 1 deletion src/PrivateKeyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
class PrivateKeyGenerator
{
private string $digestAlg;

private int $privateKeyBits;

private int $privateKeyType;

/** @var array<string, string> */
private array $additionalOptions = [];

Expand Down Expand Up @@ -51,7 +54,7 @@ public function generate(): ?PrivateKey
'private_key_type' => $this->privateKeyType,
...$this->additionalOptions,
]);
if (!$privateKey) {
if (! $privateKey) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/CsrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testExportPrivateKey(): void
$this->assertIsString($csrContent);
$this->assertStringStartsWith('-----BEGIN CERTIFICATE REQUEST-----', $csrContent);

$csrContent = (string)$csr;
$csrContent = (string) $csr;
$this->assertIsString($csrContent);
$this->assertStringStartsWith('-----BEGIN CERTIFICATE REQUEST-----', $csrContent);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/PrivateKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testExportPrivateKey(): void
$this->assertIsString($privateKeyContent);
$this->assertStringStartsWith('-----BEGIN ENCRYPTED PRIVATE KEY-----', $privateKeyContent);

$privateKeyContent = (string)$privateKey;
$privateKeyContent = (string) $privateKey;
$this->assertIsString($privateKeyContent);
$this->assertStringStartsWith('-----BEGIN ENCRYPTED PRIVATE KEY-----', $privateKeyContent);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/SubjectFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public function testSubjectFields(): void

$this->assertInstanceOf(SubjectFields::class, $subjectFields);
$this->assertIsArray($subjectFields->toArray());
$this->assertArrayHasKey('commonName', $subjectFields->toArray());$this->assertSame($commonName, Arr::get($subjectFields->toArray(), 'commonName'));
$this->assertArrayHasKey('commonName', $subjectFields->toArray());
$this->assertSame($commonName, Arr::get($subjectFields->toArray(), 'commonName'));
$this->assertSame($emailAddress, Arr::get($subjectFields->toArray(), 'emailAddress'));
$this->assertSame($countryName, Arr::get($subjectFields->toArray(), 'countryName'));
$this->assertSame($stateOrProvinceName, Arr::get($subjectFields->toArray(), 'stateOrProvinceName'));
Expand Down

0 comments on commit 997bd85

Please sign in to comment.