From 4bae5203055c1e6520a1f8102f48157ce1b3f500 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sat, 18 Sep 2021 11:25:51 +0200 Subject: [PATCH] Update composer.json, guzzle and .gitignore Additionally update test sources and README.md --- .gitignore | 34 +++++++++++++++++++++++++++++----- README.md | 8 ++++---- composer.json | 12 ++++++++---- tests/MatrixHttpApiTest.php | 10 +++++----- tests/UserTest.php | 4 ++-- 5 files changed, 48 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 06aa215..a4312b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,30 @@ -build -composer.lock -vendor phpcs.xml -phpunit.xml -.idea/ \ No newline at end of file +.idea/ + +# Created by https://www.toptal.com/developers/gitignore/api/phpunit,composer +# Edit at https://www.toptal.com/developers/gitignore?templates=phpunit,composer + +### Composer ### +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +composer.lock + +### PHPUnit ### +# Covers PHPUnit +# Reference: https://phpunit.de/ + +# Generated files +.phpunit.result.cache +.phpunit.cache + +# PHPUnit +/app/phpunit.xml +/phpunit.xml + +# Build data +/build/ + +# End of https://www.toptal.com/developers/gitignore/api/phpunit,composer diff --git a/README.md b/README.md index 6a6703d..2e79537 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Matrix client SDK for php [![Software License][ico-license]](LICENSE.md) -This is a Matrix client-server SDK for php 7.0+, mostly copied from [matrix-org/matrix-python-sdk][python-pck] +This is a Matrix client-server SDK for php 7.2.5+, mostly copied from [matrix-org/matrix-python-sdk][python-pck] This package is still a work in progress, and at the current time, not everything has been ported: - Missing E2E encryption, need php bindings for the OLM library @@ -42,15 +42,15 @@ $matrix = new MatrixHttpApi("http://localhost:8008", $sometoken); $response = $matrix->sendMessage("!roomid:matrix.org", "Hello!"); ``` -##Structure +## Structure The SDK is split into two modules: ``api`` and ``client``. -###API +### API This contains the raw HTTP API calls and has minimal business logic. You can set the access token (``token``) to use for requests as well as set a custom transaction ID (``txn_id``) which will be incremented for each request. -###Client +### Client This encapsulates the API module and provides object models such as ``Room``. diff --git a/composer.json b/composer.json index ff7abce..1f7c126 100644 --- a/composer.json +++ b/composer.json @@ -19,13 +19,14 @@ "aryess/phpmatrixsdk": "self.version" }, "require": { - "php": "~7.2", - "guzzlehttp/guzzle": "^6.3", + "php": "^7.2.5 || ^8.0", + "guzzlehttp/guzzle": "7.2.0", "rappasoft/laravel-helpers": "^1.0", "ext-json": "*" }, "require-dev": { - "phpunit/phpunit" : ">=5.4.3" + "phpunit/php-code-coverage": "^7.0", + "phpunit/phpunit": "^8.5" }, "autoload": { "psr-4": { @@ -46,6 +47,9 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "platform": { + "php": "7.2.5" + } } } diff --git a/tests/MatrixHttpApiTest.php b/tests/MatrixHttpApiTest.php index ef4d7ba..b110483 100644 --- a/tests/MatrixHttpApiTest.php +++ b/tests/MatrixHttpApiTest.php @@ -51,7 +51,7 @@ class MatrixHttpApiTest extends BaseTestCase { */ protected $api; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->api = new MatrixHttpApi('http://example.com'); } @@ -374,7 +374,7 @@ class MatrixHttpApiTest extends BaseTestCase { $req = array_get($container, '0.request'); $this->assertEquals('GET', $req->getMethod()); - $this->assertContains($this->token, $req->getRequestTarget()); + $this->assertStringContainsString($this->token, $req->getRequestTarget()); } public function testSendUserId() { @@ -390,7 +390,7 @@ class MatrixHttpApiTest extends BaseTestCase { $req = array_get($container, '0.request'); $this->assertEquals('GET', $req->getMethod()); - $this->assertContains(urlencode($this->userId), $req->getRequestTarget()); + $this->assertStringContainsString(urlencode($this->userId), $req->getRequestTarget()); } public function testSendUnsupMethod() { @@ -554,7 +554,7 @@ class MatrixHttpApiTest extends BaseTestCase { $req = array_get($container, '0.request'); $this->assertEquals('GET', $req->getMethod()); - $this->assertContains($req->getRequestTarget(), $whoamiUrl); + $this->assertStringContainsString($req->getRequestTarget(), $whoamiUrl); } public function testWhoamiUnauth() { @@ -569,4 +569,4 @@ class MatrixHttpApiTest extends BaseTestCase { } -} \ No newline at end of file +} diff --git a/tests/UserTest.php b/tests/UserTest.php index cbfe173..3460d68 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -26,7 +26,7 @@ class UserTest extends BaseTestCase { */ protected $room; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->client = new MatrixClient(self::HOSTNAME); $this->user = new User($this->client->api(), $this->userId); @@ -61,4 +61,4 @@ class UserTest extends BaseTestCase { $this->assertEquals(1, count($container)); } -} \ No newline at end of file +}