Skip to content

Commit

Permalink
Merge pull request #7 from festivalslab/support-php83
Browse files Browse the repository at this point in the history
Support PHP 8.3
  • Loading branch information
craig410 authored Oct 1, 2024
2 parents 97bb5b7 + 666df6d commit 5d4aa90
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 103 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ jobs:
fail-fast: false
matrix:
php_version:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
dependencies:
- 'default'
include:
- php_version: '8.0'
dependencies: 'lowest'
- php_version: '8.1'
dependencies: 'lowest'
- php_version: '8.2'
dependencies: 'lowest'
- php_version: '8.3'
dependencies: 'lowest'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
### Unreleased

### v2.2.0 (2024-10-01)

* Support PHP 8.3
* Drop support for PHP 8.0

### v2.1.0 (2022-10-25)

* Drop support for PHP 7.4
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
],
"require": {
"guzzlehttp/guzzle": "^7.0",
"php": "~8.0.0 || ~8.1.0 || ~8.2.0"
"php": "~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5.5",
"johnkary/phpunit-speedtrap": "^3.3"
"phpunit/phpunit": "^10.5",
"ergebnis/phpunit-slow-test-detector": "^2.15"
},
"support": {
"source": "https://github.com/festivalslab/api-client-php",
Expand Down
41 changes: 17 additions & 24 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,26 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="test/phpunit-bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
convertDeprecationsToExceptions="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
failOnDeprecation="true"
failOnNotice="true"
failOnWarning="true"
failOnRisky="true"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="unit">
<directory>test/unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
<arguments>
<array>
<element key="slowThreshold">
<integer>200</integer>
</element>
<element key="reportLength">
<integer>20</integer>
</element>
</array>
</arguments>
</listener>
</listeners>
<extensions>
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
<parameter name="maximum-count" value="20"/>
<parameter name="maximum-duration" value="200"/>
</bootstrap>
</extensions>
</phpunit>
47 changes: 22 additions & 25 deletions test/unit/EventSearchIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@
namespace test\unit\FestivalsApi;

use FestivalsApi\EventSearchIterator;
use FestivalsApi\MockFestivalsApiClient;
use IteratorAggregate;
use LogicException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use FestivalsApi\MockFestivalsApiClient;
use function iterator_count;
use function iterator_to_array;

class EventSearchIteratorTest extends TestCase
{
protected MockFestivalsApiClient $client;

public function test_it_is_initialisable()
public function test_it_is_initialisable(): void
{
$this->assertInstanceOf(EventSearchIterator::class, $this->newSubject());
}

public function test_it_is_an_iterator_aggregate()
public function test_it_is_an_iterator_aggregate(): void
{
$this->assertInstanceOf(IteratorAggregate::class, $this->newSubject());
}

public function test_it_throws_if_no_search_query_set()
public function test_it_throws_if_no_search_query_set(): void
{
$subject = $this->newSubject();
$this->expectException(LogicException::class);
Expand All @@ -38,21 +39,19 @@ public function test_it_throws_if_no_search_query_set()
iterator_to_array($subject);
}

public function test_setting_search_query_makes_no_calls_to_api()
public function test_setting_search_query_makes_no_calls_to_api(): void
{
$subject = $this->newSubject();
$subject->setQuery(['festival' => 'jazz']);
$this->client->assertZeroCallsMade();
}

/**
* @dataProvider multiple_page_dataprovider
*
* @param array $client_responses
* @param int $page_size
* @param array $expected
*/
public function test_it_iterates_api_until_no_more_events($client_responses, $page_size, $expected)
#[DataProvider('multiple_page_dataprovider')]
public function test_it_iterates_api_until_no_more_events(
array $client_responses,
int $page_size,
array $expected
): void
{
$this->client = MockFestivalsApiClient::willReturn($client_responses);

Expand All @@ -65,7 +64,7 @@ public function test_it_iterates_api_until_no_more_events($client_responses, $pa
$this->client->assertCalledWith($expected);
}

public function multiple_page_dataprovider()
public static function multiple_page_dataprovider(): array
{
return [
//no results
Expand All @@ -89,7 +88,7 @@ public function multiple_page_dataprovider()
];
}

public function test_searches_with_provided_query_overriding_size_or_from()
public function test_searches_with_provided_query_overriding_size_or_from(): void
{
$this->client = MockFestivalsApiClient::willReturn([['A', 'B',], ['C', 'D'], []]);
$subject = $this->newSubject();
Expand All @@ -107,22 +106,20 @@ public function test_searches_with_provided_query_overriding_size_or_from()
);
}

/**
* @dataProvider result_order_dataprovider
*
* @param array $client_responses
* @param int $page_size
* @param array $expected
*/
public function test_it_returns_all_results_in_correct_order($client_responses, $page_size, $expected)
#[DataProvider('result_order_dataprovider')]
public function test_it_returns_all_results_in_correct_order(
array $client_responses,
int $page_size,
array $expected
): void
{
$this->client = MockFestivalsApiClient::willReturn($client_responses);
$subject = $this->newSubject();
$subject->setQuery([], $page_size);
$this->assertEquals($expected, iterator_to_array($subject));
}

public function result_order_dataprovider(): array
public static function result_order_dataprovider(): array
{
return [
//no results
Expand All @@ -146,7 +143,7 @@ public function result_order_dataprovider(): array
];
}

public function test_it_returns_number_of_calls_to_api_made_per_search_query()
public function test_it_returns_number_of_calls_to_api_made_per_search_query(): void
{
$this->client = MockFestivalsApiClient::willReturn([['1', '2',], ['3']]);
$subject = $this->newSubject();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/FestivalsApiClientFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
class FestivalsApiClientFactoryTest extends TestCase
{

public function test_it_creates_client_without_credentials()
public function test_it_creates_client_without_credentials(): void
{
$this->assertInstanceOf(
FestivalsApiClient::class,
FestivalsApiClientFactory::create()
);
}

public function test_it_creates_client_with_credentials_set()
public function test_it_creates_client_with_credentials_set(): void
{
$this->assertInstanceOf(
FestivalsApiClient::class,
Expand Down
Loading

0 comments on commit 5d4aa90

Please sign in to comment.