Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The big fat modernization #65

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a8db498
First sweep
lstrojny May 10, 2021
1e31b63
Next
lstrojny May 10, 2021
86febba
Next
lstrojny May 10, 2021
d070626
Next
lstrojny May 10, 2021
4b7478d
Final
lstrojny May 11, 2021
5b25146
CI
lstrojny May 11, 2021
99909ae
Next
lstrojny May 11, 2021
de52fa3
CI
lstrojny May 11, 2021
dc87f31
PHP 8
lstrojny May 11, 2021
df2a529
PHPUnit upgrade
lstrojny May 11, 2021
0e9c41e
Next
lstrojny May 11, 2021
f537cf8
Next
lstrojny May 11, 2021
241adf4
Next
lstrojny May 11, 2021
1a53f3b
increase lower bound
lstrojny May 11, 2021
1bbbf62
Symfony request instead of Guzzle request
lstrojny May 11, 2021
020cd2e
Cleanup
lstrojny May 11, 2021
538efd3
increase lower bound
lstrojny May 11, 2021
fd63936
increase lower bound
lstrojny May 11, 2021
3f251e1
increase lower bound
lstrojny May 11, 2021
6d29e21
Different closure library
lstrojny May 11, 2021
f220cbf
Next
lstrojny May 11, 2021
677e690
Next
lstrojny May 11, 2021
54da25f
Portability
lstrojny May 11, 2021
f958879
Next
lstrojny May 11, 2021
b2c67e7
Newer Guzzle
lstrojny May 11, 2021
dc3d987
PSR initial port
lstrojny May 12, 2021
68d867e
JIT disabled
lstrojny May 12, 2021
13f2853
Next
lstrojny May 12, 2021
3243c46
Next
lstrojny May 12, 2021
128a5c9
Turn off union type hints
lstrojny May 12, 2021
5811f42
Turn off mixed types
lstrojny May 12, 2021
d754277
Replace Silex
lstrojny May 17, 2021
edfe137
Refactor storage
lstrojny May 18, 2021
8717042
Unused use statements
lstrojny May 18, 2021
8a34c39
Next
lstrojny May 18, 2021
fbd0748
Introduce dependency tracking
lstrojny May 18, 2021
e83a259
Forward compat
lstrojny May 19, 2021
cd52a62
Fix dependencies
lstrojny May 19, 2021
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
23 changes: 19 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ on: [push, pull_request]

jobs:
test:
name: PHP ${{ matrix.php-version }} (${{ matrix.experimental && 'experimental' || 'full support' }})
name: PHP ${{ matrix.php-version }} (${{ matrix.experimental && 'experimental' || 'full support' }}, ${{ matrix.dependencies }} dependencies)

runs-on: ubuntu-18.04

strategy:
fail-fast: false
matrix:
php-version:
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
experimental: [false]
dependencies: [lowest, stable]
include:
- php-version: 8.1
experimental: true
dependencies: lowest
- php-version: 8.1
experimental: true
dependencies: stable

continue-on-error: ${{ matrix.experimental }}
steps:
Expand All @@ -34,6 +40,7 @@ jobs:
uses: ramsey/composer-install@v1
with:
composer-options: --prefer-dist
dependency-versions: ${{ matrix.dependencies }}
continue-on-error: ${{ matrix.experimental }}

- name: Setup PCOV
Expand All @@ -45,3 +52,11 @@ jobs:
- name: Run Tests
run: composer tests
continue-on-error: ${{ matrix.experimental }}

- name: Check coding style
run: composer coding-style
continue-on-error: ${{ matrix.experimental }}

- name: Check dependencies
run: composer dependencies
continue-on-error: ${{ matrix.experimental }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
vendor/
composer.lock
.idea/
state/*-*
var/
build/*
phpunit.xml
.phpunit.result.cache
.deptrac.cache
38 changes: 27 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@
}
],
"require": {
"php": "~7.1",
"silex/silex": "~2.0",
"guzzle/guzzle": ">=3.8",
"symfony/process": "~3|~4|~5",
"jeremeamia/superclosure": "~2",
"lstrojny/hmmmath": ">=0.5.0"
},
"php": "~7.4|~8.0",
"symfony/process": "~4.4|~5",
"lstrojny/hmmmath": ">=0.5.0",
"slevomat/coding-standard": "^7.0",
"opis/closure": "^3.6",
"guzzlehttp/guzzle": "^7.3",
"psr/http-factory": "^1.0",
"guzzlehttp/psr7": "^1.8",
"http-interop/http-factory-guzzle": "^1.0",
"php-http/discovery": "^1.13",
"symfony/config": "~4.4|~5",
"symfony/http-kernel": "~4.4|~5",
"symfony/http-foundation": "~4.4|~5",
"symfony/routing": "~4.4|~5",
"symfony/dependency-injection": "~4.4|~5",
"symfony/framework-bundle": "~4.4|~5"
},
"require-dev": {
"internations/kodierungsregelwerksammlung": "~0.23.0",
"internations/testing-component": "1.0.1",
"phpunit/phpunit": "^7"
"phpunit/phpunit": "^9",
"qossmic/deptrac-shim": "^0.13.0"
},
"autoload": {
"psr-4": {"InterNations\\Component\\HttpMock\\": "src/"}
Expand All @@ -32,6 +41,13 @@
"psr-4": {"InterNations\\Component\\HttpMock\\Tests\\": "tests/"}
},
"scripts": {
"tests": "phpunit"
"tests": "phpunit",
"coding-style": "phpcs",
"dependencies": "deptrac",
"checkup": [
"@composer tests",
"@composer coding-style",
"@composer dependencies"
]
}
}
126 changes: 126 additions & 0 deletions depfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
paths:
- ./src
- ./tests
- ./vendor/psr
- ./vendor/guzzlehttp
- ./vendor/phpunit
- ./vendor/opis
exclude_files:
- '#vendor/.*test.*#'
layers:
- name: "HTTP Mock Client"
collectors:
- type: className
regex: ^InterNations\\Component\\HttpMock\\(?!Tests\\|Server\\|Util|Http|ServerProcess).*
- name: "HTTP Mock PSR Middleware"
collectors:
- type: className
regex: ^InterNations\\Component\\HttpMock\\Http\\.*
- name: "HTTP Mock Server Process"
collectors:
- type: className
regex: ^InterNations\\Component\\HttpMock\\ServerProcess$
- name: "HTTP Mock Server"
collectors:
- type: className
regex: ^InterNations\\Component\\HttpMock\\Server\\.+
- name: "HTTP Mock Util"
collectors:
- type: className
regex: ^InterNations\\Component\\HttpMock\\Util$
- name: "HTTP Mock Tests"
collectors:
- type: className
regex: ^InterNations\\Component\\HttpMock\\Tests\\.+
- name: "PSR HTTP"
collectors:
- type: className
regex: ^Psr\\Http\\.*
- name: "PSR Logger"
collectors:
- type: className
regex: ^Psr\\Log\\.*
- name: "PSR HTTP Discovery"
collectors:
- type: className
regex: ^Http\\Discovery\\*
- name: Guzzle
collectors:
- type: className
regex: ^GuzzleHttp\\.*
- name: PHPUnit
collectors:
- type: className
regex: ^(PHPUnit|SebastianBergmann|DeepCopy|Prophecy|TheSeer|PharIo|Doctrine|Webmozart|PhpParser|phpDocumentor|Composer|Symfony\\Polyfill)\\.*
- name: "Symfony HttpFoundation Component"
collectors:
- type: className
regex: ^Symfony\\Component\\HttpFoundation\\.*
- name: "Symfony Framework Bundle"
collectors:
- type: className
regex: ^Symfony\\Bundle\\FrameworkBundle\\.*
- name: "Symfony HttpKernel Component"
collectors:
- type: className
regex: ^Symfony\\Component\\HttpKernel\\.*
- name: "Symfony DependencyInjection Component"
collectors:
- type: className
regex: ^Symfony\\Component\\DependencyInjection\\.*
- name: "Symfony Routing Component"
collectors:
- type: className
regex: ^Symfony\\Component\\Routing\\.*
- name: "Symfony Process Component"
collectors:
- type: className
regex: ^Symfony\\Component\\Process\\.*
- name: "Opis Serializable Closure"
collectors:
- type: className
regex: ^(Opis\\Closure|SuperClosure)
- name: "hmmmath Fibonacci"
collectors:
- type: className
regex: ^hmmmath\\Fibonacci\\.*
ruleset:
"HTTP Mock Client":
- "Opis Serializable Closure"
- "HTTP Mock Util"
- "HTTP Mock Server Process"
- "PSR HTTP"
- "PSR HTTP Discovery"
- "Symfony HttpFoundation Component"
"HTTP Mock Server Process":
- "hmmmath Fibonacci"
- "Symfony Process Component"
- "PSR HTTP"
- "PSR HTTP Discovery"
- "HTTP Mock PSR Middleware"
- "HTTP Mock Client"
"HTTP Mock Server":
- "Symfony HttpFoundation Component"
- "Symfony HttpKernel Component"
- "Symfony DependencyInjection Component"
- "Symfony Routing Component"
- "Symfony Framework Bundle"
- "HTTP Mock Util"
"HTTP Mock Tests":
- "HTTP Mock Client"
- "HTTP Mock Server Process"
- "Symfony HttpFoundation Component"
- "Opis Serializable Closure"
- "HTTP Mock Util"
- "PSR HTTP"
- "PSR HTTP Discovery"
- PHPUnit
"HTTP Mock Util": ~
"HTTP Mock PSR Middleware":
- "PSR HTTP"
Guzzle:
- "PSR HTTP"
- "PSR Logger"
PHPUnit: ~
"PSR Logger":
- PHPUnit
27 changes: 14 additions & 13 deletions doc/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,34 @@ server in `setUpBeforeClass()` and `tearDownAfterClass()` respectively.
```php
namespace Acme\Tests;

use InterNations\Component\HttpMock\PHPUnit\HttpMockTrait;
use PHPUnit\Framework\TestCase;
use InterNations\Component\HttpMock\PHPUnit\HttpMock;

class ExampleTest extends PHPUnit_Framework_TestCase
class ExampleTest extends TestCase
{
use HttpMockTrait;
use HttpMock;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
static::setUpHttpMockBeforeClass('8082', 'localhost');
}

public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
static::tearDownHttpMockAfterClass();
}

public function setUp()
protected function setUp(): void
{
$this->setUpHttpMock();
}

public function tearDown()
protected function tearDown(): void
{
$this->tearDownHttpMock();
}

public function testSimpleRequest()
public function testSimpleRequest(): void
{
$this->http->mock
->when()
Expand All @@ -44,10 +45,10 @@ class ExampleTest extends PHPUnit_Framework_TestCase
->end();
$this->http->setUp();

$this->assertSame('mocked body', file_get_contents('http://localhost:8082/foo'));
self::assertSame('mocked body', file_get_contents('http://localhost:8082/foo'));
}

public function testAccessingRecordedRequests()
public function testAccessingRecordedRequests(): void
{
$this->http->mock
->when()
Expand All @@ -58,10 +59,10 @@ class ExampleTest extends PHPUnit_Framework_TestCase
->end();
$this->http->setUp();

$this->assertSame('mocked body', $this->http->client->post('http://localhost:8082/foo')->send()->getBody(true));
self::assertSame('mocked body', $this->http->client->post('http://localhost:8082/foo')->send()->getBody(true));

$this->assertSame('POST', $this->http->requests->latest()->getMethod());
$this->assertSame('/foo', $this->http->requests->latest()->getPath());
self::assertSame('POST', $this->http->requests->latest()->getMethod());
self::assertSame('/foo', $this->http->requests->latest()->getPath());
}
}
```
76 changes: 76 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0"?>
<ruleset name="HTTP Mock">
<config name="installed_paths" value="../../slevomat/coding-standard"/>
<file>./src</file>
<file>./tests</file>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<property name="enableUnionTypeHint" value="false" type="bool"/>
<property name="enableMixedTypeHint" value="false" type="bool"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableUnionTypeHint" value="false" type="bool"/>
<property name="enableMixedTypeHint" value="false" type="bool"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableUnionTypeHint" value="false" type="bool"/>
<property name="enableMixedTypeHint" value="false" type="bool"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<rule ref="SlevomatCodingStandard.Classes.ForbiddenPublicProperty"/>
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedParameter"/>
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true" type="bool"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<rule ref="SlevomatCodingStandard.PHP.DisallowReference"/>
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition"/>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousErrorNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator"/>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
</ruleset>
Loading