diff --git a/.github/workflows/cs-tests.yml b/.github/workflows/styles.yml similarity index 58% rename from .github/workflows/cs-tests.yml rename to .github/workflows/styles.yml index d75a7cb..86a1b31 100644 --- a/.github/workflows/cs-tests.yml +++ b/.github/workflows/styles.yml @@ -1,4 +1,4 @@ -name: Static Code Anylzer & Tests +name: Code styles on: push: schedule: @@ -13,7 +13,7 @@ jobs: uses: shivammathur/setup-php@v2 with: tools: composer:v2 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: composer install --prefer-dist - uses: symfonycorp/security-checker-action@v3 @@ -26,7 +26,7 @@ jobs: with: tools: composer:v2, phpcpd - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v4 - run: composer install --prefer-dist - run: ./vendor/bin/phpcpd ./ --exclude=vendor --exclude=bin --exclude=tests @@ -39,7 +39,7 @@ jobs: with: tools: composer:v2, php-cs-fixer, cs2pr - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v4 - run: composer install --prefer-dist - run: ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --dry-run --using-cache=no --format=checkstyle | cs2pr @@ -49,30 +49,6 @@ jobs: steps: - name: Setup PHP uses: shivammathur/setup-php@v2 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: composer install --prefer-dist - run: ./vendor/bin/psalm --output-format=github - - tests: - runs-on: ubuntu-latest - strategy: - matrix: - php-versions: ['8.0', '8.1', '8.2'] - steps: - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - tools: composer:v2 - php-version: ${{ matrix.php-versions }} - - uses: actions/checkout@v2 - - uses: php-actions/composer@v6 - with: - php_version: ${{ matrix.php-versions }} - version: 2 - - run: XDEBUG_MODE=coverage ./vendor/bin/phpunit - - name: Upload coverage results to Coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - composer global require php-coveralls/php-coveralls - php-coveralls --coverage_clover=build/logs/clover.xml -v diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..deffb6c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,31 @@ +name: Tests +on: + push: + schedule: + - cron: '0 0 * * THU' + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + matrix: + php-versions: ['8.0', '8.1', '8.2', '8.3'] + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + tools: composer:v2 + php-version: ${{ matrix.php-versions }} + - uses: actions/checkout@v4 + - uses: php-actions/composer@v6 + with: + php_version: ${{ matrix.php-versions }} + version: 2 + - run: XDEBUG_MODE=coverage ./vendor/bin/phpunit + - name: Upload coverage results to Coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + composer global require php-coveralls/php-coveralls + php-coveralls --coverage_clover=build/logs/clover.xml -v diff --git a/CHANGELOG.md b/CHANGELOG.md index e5b3b90..eb6bc30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - run tests over multiple PHP version +- add tests on PHP 8.3 ### Security - update friendsofphp/php-cs-fixer (v3.4.0 => v3.21.1) diff --git a/README.md b/README.md index b01f83b..aa2da53 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,11 @@ Super-simple, minimum abstraction Pricehubble API v1.x wrapper, in PHP. I hate complex wrappers. This lets you get from the Pricehubble API docs to the code as directly as possible. -Requires PHP 7.4+. Abstraction is for chimps. - -[![Build](https://github.com/antistatique/pricehubble-php-sdk/actions/workflows/cs-tests.yml/badge.svg)](https://github.com/antistatique/pricehubble-php-sdk/actions/workflows/cs-tests.yml) +[![Build](https://github.com/antistatique/pricehubble-php-sdk/actions/workflows/tests.yml/badge.svg)](https://github.com/antistatique/pricehubble-php-sdk/actions/workflows/tests.yml) [![Coverage Status](https://coveralls.io/repos/github/antistatique/pricehubble-php-sdk/badge.svg)](https://coveralls.io/github/antistatique/pricehubble-php-sdk) [![Packagist](https://img.shields.io/packagist/dt/antistatique/pricehubble-php-sdk.svg?maxAge=2592000)](https://packagist.org/packages/antistatique/pricehubble-php-sdk) [![License](https://poser.pugx.org/antistatique/pricehubble-php-sdk/license)](https://packagist.org/packages/antistatique/pricehubble-php-sdk) +[![PHP Versions Supported](https://img.shields.io/badge/php-%3E%3D%208.0-8892BF.svg)](https://packagist.org/packages/antistatique/pricehubble-php-sdk) Getting started ------------ diff --git a/examples/templates/base.php b/examples/templates/base.php index e471f55..14eea52 100644 --- a/examples/templates/base.php +++ b/examples/templates/base.php @@ -3,7 +3,7 @@ include_once \dirname(__DIR__).'/../vendor/autoload.php'; if (!\class_exists('Symfony\Component\Dotenv\Dotenv')) { - throw new \RuntimeException('You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.'); + throw new RuntimeException('You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.'); } $env = \dirname(__DIR__).'/.env'; @@ -12,15 +12,15 @@ $dotenv = new Symfony\Component\Dotenv\Dotenv($env); $dotenv->load($env); } else { - throw new \RuntimeException('You need to define a .env file.'); + throw new RuntimeException('You need to define a .env file.'); } function getEnvVariables() { return [ - 'PRICEHUBBLE_USERNAME' => $_ENV['PRICEHUBBLE_USERNAME'], - 'PRICEHUBBLE_PASS' => $_ENV['PRICEHUBBLE_PASS'], - ]; + 'PRICEHUBBLE_USERNAME' => $_ENV['PRICEHUBBLE_USERNAME'], + 'PRICEHUBBLE_PASS' => $_ENV['PRICEHUBBLE_PASS'], + ]; } /* Ad hoc functions to make the examples marginally prettier. */ diff --git a/src/Pricehubble.php b/src/Pricehubble.php index 4cd8534..aace8f8 100644 --- a/src/Pricehubble.php +++ b/src/Pricehubble.php @@ -493,10 +493,10 @@ protected function prepareStateForRequest(string $http_verb, string $url, int $t ]; $this->lastRequest = $parts + [ - 'method' => $http_verb, - 'body' => '', - 'timeout' => $timeout, - ]; + 'method' => $http_verb, + 'body' => '', + 'timeout' => $timeout, + ]; return $this->lastResponse; } diff --git a/src/Resource/AbstractResource.php b/src/Resource/AbstractResource.php index 4327300..faaf820 100644 --- a/src/Resource/AbstractResource.php +++ b/src/Resource/AbstractResource.php @@ -12,15 +12,15 @@ abstract class AbstractResource implements ResourceInterface /** * The Pricehubble base API instance. * - * @var \Antistatique\Pricehubble\Pricehubble + * @var Pricehubble */ private Pricehubble $pricehubble; /** * Construct a new AbstractApi object. * - * @param \Antistatique\Pricehubble\Pricehubble $pricehubble - * The Pricehubble base API class + * @param Pricehubble $pricehubble + * The Pricehubble base API class */ public function __construct(Pricehubble $pricehubble) { @@ -30,7 +30,7 @@ public function __construct(Pricehubble $pricehubble) /** * Set the API provider. * - * @param \Antistatique\Pricehubble\Pricehubble $pricehubble the Pricehubble base API instance + * @param Pricehubble $pricehubble the Pricehubble base API instance * * @return $this */ diff --git a/src/Resource/ResourceInterface.php b/src/Resource/ResourceInterface.php index e03c4e7..f14d05c 100644 --- a/src/Resource/ResourceInterface.php +++ b/src/Resource/ResourceInterface.php @@ -12,8 +12,8 @@ interface ResourceInterface /** * Get the API provider. * - * @return \Antistatique\Pricehubble\Pricehubble - * The Pricehubble base API instance + * @return Pricehubble + * The Pricehubble base API instance */ public function getPricehubble(): Pricehubble; } diff --git a/tests/Unit/PricehubbleAttachRequestPayloadTest.php b/tests/Unit/PricehubbleAttachRequestPayloadTest.php index d76e72a..782bfac 100644 --- a/tests/Unit/PricehubbleAttachRequestPayloadTest.php +++ b/tests/Unit/PricehubbleAttachRequestPayloadTest.php @@ -23,7 +23,7 @@ final class PricehubbleAttachRequestPayloadTest extends TestCase /** * The Pricehubble base API instance. * - * @var \Antistatique\Pricehubble\Pricehubble + * @var Pricehubble */ private Pricehubble $pricehubble; diff --git a/tests/Unit/PricehubbleTest.php b/tests/Unit/PricehubbleTest.php index e2f38b3..fe212b3 100644 --- a/tests/Unit/PricehubbleTest.php +++ b/tests/Unit/PricehubbleTest.php @@ -24,7 +24,7 @@ final class PricehubbleTest extends TestCase /** * The Pricehubble base API instance. * - * @var \Antistatique\Pricehubble\Pricehubble + * @var Pricehubble */ private Pricehubble $pricehubble; @@ -450,8 +450,8 @@ public function testDetermineSuccess401MissingToken() $this->expectExceptionMessage('401 invalid_request: The access token is missing'); $this->callPrivateMethod($pricehubble_mock, 'determineSuccess', [ $response, [ - 'error_description' => 'The access token is missing', - 'error' => 'invalid_request', + 'error_description' => 'The access token is missing', + 'error' => 'invalid_request', ], 0, ]); } @@ -469,8 +469,8 @@ public function testDetermineSuccess403MissingProperty() $this->expectExceptionMessage("403 'dossierId', 'simulationId' or 'buildingId' is a required property"); $this->callPrivateMethod($pricehubble_mock, 'determineSuccess', [ $response, [ - 'message' => "'dossierId', 'simulationId' or 'buildingId' is a required property", - ], 0, + 'message' => "'dossierId', 'simulationId' or 'buildingId' is a required property", + ], 0, ]); } diff --git a/tests/Unit/Resource/PointsOfInterestTest.php b/tests/Unit/Resource/PointsOfInterestTest.php index 4bed780..7919442 100644 --- a/tests/Unit/Resource/PointsOfInterestTest.php +++ b/tests/Unit/Resource/PointsOfInterestTest.php @@ -149,20 +149,20 @@ public function testGatherReturnsExpected(): void 'category' => 'education', 'distance' => 256, 'location' => [ - 'address' => [ - 'city' => 'Lausanne', - 'houseNumber' => '26-28', - 'postCode' => '1004', - 'street' => 'Avenue de Provence', - ], + 'address' => [ + 'city' => 'Lausanne', + 'houseNumber' => '26-28', + 'postCode' => '1004', + 'street' => 'Avenue de Provence', + ], 'coordinates' => [ - 'latitude' => 46.5234680175781, - 'longitude' => 6.6108078956604, - ], + 'latitude' => 46.5234680175781, + 'longitude' => 6.6108078956604, ], - 'name' => 'Gymnase Provence', - 'subcategory' => 'university', ], + 'name' => 'Gymnase Provence', + 'subcategory' => 'university', + ], 8 => [ 'category' => 'education', 'distance' => 261, diff --git a/tests/Unit/Resource/ValuationTest.php b/tests/Unit/Resource/ValuationTest.php index f7ed3f7..88a1018 100644 --- a/tests/Unit/Resource/ValuationTest.php +++ b/tests/Unit/Resource/ValuationTest.php @@ -32,35 +32,35 @@ public function testFullReturnsExpected(): void $response = json_decode(file_get_contents(__DIR__.'/../../responses/valuation-full.json'), true, 512, JSON_THROW_ON_ERROR); $fullParams = [ - 'dealType' => 'sale', - 'valuationInputs' => [ - [ - 'property' => [ - 'location' => [ - 'address' => [ - 'postCode' => 8037, - 'city' => 'Zürich', - 'street' => 'Nordstrasse', - 'houseNumber' => '391', - ], - ], - 'buildingYear' => 1850, - 'livingArea' => 130, - 'propertyType' => [ - 'code' => 'apartment', - 'subcode' => 'apartment_normal', + 'dealType' => 'sale', + 'valuationInputs' => [ + [ + 'property' => [ + 'location' => [ + 'address' => [ + 'postCode' => 8037, + 'city' => 'Zürich', + 'street' => 'Nordstrasse', + 'houseNumber' => '391', + ], + ], + 'buildingYear' => 1850, + 'livingArea' => 130, + 'propertyType' => [ + 'code' => 'apartment', + 'subcode' => 'apartment_normal', + ], + 'numberOfRooms' => 5, + 'gardenArea' => 25, + 'balconyArea' => 5, + 'numberOfIndoorParkingSpaces' => 1, + 'numberOfOutdoorParkingSpaces' => 2, + 'numberOfBathrooms' => 2, + 'renovationYear' => 2019, + ], ], - 'numberOfRooms' => 5, - 'gardenArea' => 25, - 'balconyArea' => 5, - 'numberOfIndoorParkingSpaces' => 1, - 'numberOfOutdoorParkingSpaces' => 2, - 'numberOfBathrooms' => 2, - 'renovationYear' => 2019, - ], ], - ], - 'countryCode' => 'CH', + 'countryCode' => 'CH', ]; $pricehubble_mock = $this->getMockBuilder(Pricehubble::class) ->onlyMethods(['makeRequest'])