diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..58bbeb8
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,33 @@
+name: CI
+
+on: [push, pull_request]
+
+jobs:
+ tests:
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ php: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0]
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ coverage: none
+
+ - name: Validate composer.json and composer.lock
+ run: composer validate
+
+ - name: Install dependencies
+ run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
+
+ - name: Check code style
+ run: vendor/bin/phpcs
+
+ - name: Run test suite
+ run: vendor/bin/phpunit
\ No newline at end of file
diff --git a/composer.json b/composer.json
index f0ec57d..8048419 100644
--- a/composer.json
+++ b/composer.json
@@ -17,8 +17,8 @@
"psr/http-factory": "^1.0"
},
"require-dev": {
- "nyholm/psr7": "^1.3",
- "phpunit/phpunit": "^6.5",
+ "guzzlehttp/psr7": "^1.7",
+ "phpunit/phpunit": ">=6.5",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
@@ -35,6 +35,7 @@
},
"autoload-dev": {
"psr-4": {
+ "Stuff\\Webclient\\Helper\\Form\\": "stuff/",
"Tests\\Webclient\\Helper\\Form\\": "tests/"
}
}
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 7d9a4eb..cfe50aa 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -15,4 +15,5 @@
src
tests
+ stuff
\ No newline at end of file
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 66b98f0..6f90c5c 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,5 +1,5 @@
-
+
tests
diff --git a/stuff/HttpFactory.php b/stuff/HttpFactory.php
new file mode 100644
index 0000000..379b1cd
--- /dev/null
+++ b/stuff/HttpFactory.php
@@ -0,0 +1,46 @@
+createStreamFromResource($resource);
+ }
+
+ public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
+ {
+ $resource = fopen($filename, $mode);
+ return $this->createStreamFromResource($resource);
+ }
+
+ public function createStreamFromResource($resource): StreamInterface
+ {
+ return new Stream($resource);
+ }
+}
diff --git a/tests/FormTest.php b/tests/FormTest.php
index 63fbf5c..e5c5a5a 100644
--- a/tests/FormTest.php
+++ b/tests/FormTest.php
@@ -5,10 +5,8 @@
namespace Tests\Webclient\Helper\Form;
use InvalidArgumentException;
-use Nyholm\Psr7\Factory\Psr17Factory;
use PHPUnit\Framework\TestCase;
-use Psr\Http\Message\ResponseFactoryInterface;
-use Psr\Http\Message\StreamFactoryInterface;
+use Stuff\Webclient\Helper\Form\HttpFactory;
use Webclient\Helper\Form\Form;
use function dirname;
@@ -20,24 +18,6 @@
class FormTest extends TestCase
{
- /**
- * @var ResponseFactoryInterface
- */
- private $responseFactory;
-
- /**
- * @var StreamFactoryInterface
- */
- private $streamFactory;
-
- public function setUp()
- {
- parent::setUp();
- $factory = new Psr17Factory();
- $this->responseFactory = $factory;
- $this->streamFactory = $factory;
- }
-
/**
* @param string $method
* @param string $uri
@@ -266,6 +246,7 @@ public function provideConstruct()
private function getForm(string $uri, string $method): Form
{
- return new Form($this->responseFactory, $this->streamFactory, $uri, $method);
+ $factory = new HttpFactory();
+ return new Form($factory, $factory, $uri, $method);
}
}
diff --git a/tests/WizardTest.php b/tests/WizardTest.php
index 65f5229..583530a 100644
--- a/tests/WizardTest.php
+++ b/tests/WizardTest.php
@@ -4,8 +4,8 @@
namespace Tests\Webclient\Helper\Form;
-use Nyholm\Psr7\Factory\Psr17Factory;
use PHPUnit\Framework\TestCase;
+use Stuff\Webclient\Helper\Form\HttpFactory;
use Webclient\Helper\Form\Form;
use Webclient\Helper\Form\Wizard;
@@ -19,7 +19,7 @@ class WizardTest extends TestCase
*/
public function testCreateForm(string $method, string $uri)
{
- $factory = new Psr17Factory();
+ $factory = new HttpFactory();
$wizard = new Wizard($factory, $factory);
$form = $wizard->createForm($uri, $method);
$this->assertInstanceOf(Form::class, $form);