Skip to content

Commit 3a53481

Browse files
authored
PHP Versions Matrix testing (#32)
* OS Matrix testing with actual PHP versions see https://www.php.net/supported-versions.php * Fixing tests on Windows
1 parent 8b58842 commit 3a53481

5 files changed

Lines changed: 37 additions & 5 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
1616

1717
- name: Validate composer.json and composer.lock
1818
run: composer validate
@@ -32,5 +32,5 @@ jobs:
3232

3333
- name: Run test suite
3434
env:
35-
TEST_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
35+
TEST_CONFIGURATION_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
3636
run: composer run-script test

.github/workflows/php-versions.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: PHP Versions
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
run:
11+
runs-on: ${{ matrix.operating-system }}
12+
strategy:
13+
matrix:
14+
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
15+
php-versions: ['7.3', '8.0', '8.1']
16+
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- name: Install PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-versions }}
24+
- name: Install dependencies
25+
run: composer install --prefer-dist --no-progress --no-suggest
26+
27+
- name: Run test suite
28+
env:
29+
TEST_CONFIGURATION_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
30+
run: composer run-script test

index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
$config = new Configuration();
3939
$config->setClientId('ClientId from https://dashboard.aspose.cloud/applications');
4040
$config->setClientSecret('Client Secret from https://dashboard.aspose.cloud/applications');
41-
if (getenv("TEST_ACCESS_TOKEN")) {
42-
$config->setAccessToken(getenv("TEST_ACCESS_TOKEN"));
41+
if (getenv("TEST_CONFIGURATION_ACCESS_TOKEN")) {
42+
$config->setAccessToken(getenv("TEST_CONFIGURATION_ACCESS_TOKEN"));
4343
}
4444

4545
$request = new GetBarcodeGenerateRequest(EncodeBarcodeType::QR, 'PHP SDK Test');

tests/ConfigurationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public function testConfigurationJsonEncode(): void
2222
$config->setAccessToken('access token');
2323

2424
$json = json_encode($config, JSON_PRETTY_PRINT);
25+
// Fix line endings on Windows
26+
$json = preg_replace("/(?<=[^\r]|^)\n/", PHP_EOL, $json);
2527

2628
$this->assertEquals(
2729
'{

tests/TestConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function fromEnv(string $prefix): Configuration
6060
return $config;
6161
}
6262

63-
public static function fromFileOrEnv(string $filename = 'Configuration.json', string $prefix = 'TEST_'): Configuration
63+
public static function fromFileOrEnv(string $filename = 'Configuration.json', string $prefix = 'TEST_CONFIGURATION_'): Configuration
6464
{
6565
$contents = false;
6666
try {

0 commit comments

Comments
 (0)