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

add tests on PHP 8.3 #19

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 5 additions & 29 deletions .github/workflows/cs-tests.yml → .github/workflows/styles.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Static Code Anylzer & Tests
name: Code styles
on:
push:
schedule:
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
31 changes: 31 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------
Expand Down
10 changes: 5 additions & 5 deletions examples/templates/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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. */
Expand Down
8 changes: 4 additions & 4 deletions src/Pricehubble.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Resource/AbstractResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Resource/ResourceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion tests/Unit/PricehubbleAttachRequestPayloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class PricehubbleAttachRequestPayloadTest extends TestCase
/**
* The Pricehubble base API instance.
*
* @var \Antistatique\Pricehubble\Pricehubble
* @var Pricehubble
*/
private Pricehubble $pricehubble;

Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/PricehubbleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class PricehubbleTest extends TestCase
/**
* The Pricehubble base API instance.
*
* @var \Antistatique\Pricehubble\Pricehubble
* @var Pricehubble
*/
private Pricehubble $pricehubble;

Expand Down Expand Up @@ -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,
]);
}
Expand All @@ -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,
]);
}

Expand Down
22 changes: 11 additions & 11 deletions tests/Unit/Resource/PointsOfInterestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
54 changes: 27 additions & 27 deletions tests/Unit/Resource/ValuationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
Loading