Skip to content

Commit

Permalink
ci(php): Add PHP installation on prefer lowest with PHP 7.1. (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptondereau authored Sep 15, 2020
1 parent 05dc8fc commit df58b29
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI
name: Tests

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
run:
Expand All @@ -19,19 +25,25 @@ jobs:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2
- name: Install PHP 8 Dependencies
- name: Install PHP 7 Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress --ignore-platform-req=php
if: "matrix.php >= 8"
- name: Install PHP 7 Dependencies
command: composer update --no-interaction --prefer-dist --no-progress
if: "matrix.php < 8 && matrix.php > 7.1"
- name: Install PHP 7 Dependencies lowest
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --prefer-dist --no-progress
if: "matrix.php < 8"
command: composer update --no-interaction --prefer-lowest --no-progress
if: "matrix.php == 7.1"
- name: Install PHP 8 Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress --ignore-platform-req=php
if: "matrix.php >= 8"
- run: vendor/bin/phpunit --coverage-text

2 changes: 1 addition & 1 deletion tests/Ups/Tests/QuantumViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testGetSubscription()
$this->assertObjectHasAttribute('Type', $events->offsetGet(0));

// Test bookmarks
$this->assertIsBool($quantumView->hasBookmark());
$this->assertTrue(\is_bool($quantumView->hasBookmark()));
}

public function testSubscriptionContext()
Expand Down
11 changes: 6 additions & 5 deletions tests/Ups/Tests/SimpleAddressValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
use Exception;
use PHPUnit\Framework\TestCase;
use Ups;
use Ups\Entity\Address;

class SimpleAddressValidationTest extends TestCase
{
public function testCreateRequest()
{
$validator = new Ups\SimpleAddressValidation();

$address = new \Ups\Entity\Address();
$address = new Address();
$address->setStateProvinceCode('NY');
$address->setCity('NYork');
$address->setCountryCode('US');
Expand All @@ -36,21 +37,21 @@ public function testResponse()
$validator = new Ups\SimpleAddressValidation();
$validator->setRequest($request = new RequestMock(null, '/SimpleAddressValidation/Response1.xml'));

$address = new \Ups\Entity\Address();
$address = new Address();
$address->setStateProvinceCode('NY');
$address->setCity('NYork');
$address->setCountryCode('US');
$address->setPostalCode('10118');
$result = $validator->validate($address);

// Test response
$this->assertIsArray($result);
$this->assertTrue(is_array($result));
$this->assertCount(6, $result);

$first = $result[0];
$this->assertInstanceOf('stdClass', $first);
$this->assertEquals(1, $first->Rank);
$this->assertIsString($first->Quality);
$this->assertTrue(is_string($first->Quality));
$this->assertEquals('0.9875', $first->Quality);
$this->assertInstanceOf('stdClass', $first->Address);
$this->assertEquals('NEW YORK', $first->Address->City);
Expand All @@ -61,7 +62,7 @@ public function testResponse()
$last = $result[5];
$this->assertInstanceOf('stdClass', $last);
$this->assertEquals(6, $last->Rank);
$this->assertIsString($last->Quality);
$this->assertTrue(is_string($first->Quality));
$this->assertEquals('0.9875', $last->Quality);
$this->assertInstanceOf('stdClass', $last->Address);
$this->assertEquals('NYC', $last->Address->City);
Expand Down
16 changes: 8 additions & 8 deletions tests/Ups/Tests/TimeInTransitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
use Ups\Entity\ShipmentWeight;
use Ups\Entity\TimeInTransitRequest;
use Ups\Entity\UnitOfMeasurement;
use Ups\TimeInTransit;

class TimeInTransitTest extends TestCase
{
public function testCreateRequest()
{
$tit = new Ups\TimeInTransit();
$tit = new TimeInTransit();
$tit->setRequest($request = new RequestMock());

$data = new TimeInTransitRequest();
Expand Down Expand Up @@ -82,7 +83,7 @@ public function testCreateRequest()

public function testRequest()
{
$tit = new Ups\TimeInTransit();
$tit = new TimeInTransit();
$tit->setRequest($request = new RequestMock(null, '/TimeInTransit/Response1.xml'));
$times = $tit->getTimeInTransit(new TimeInTransitRequest());

Expand All @@ -93,7 +94,7 @@ public function testRequest()
$this->assertInstanceOf('\Ups\Entity\ShipmentWeight', $times->ShipmentWeight);
$this->assertInstanceOf('\Ups\Entity\Charges', $times->InvoiceLineTotal);
$this->assertInstanceOf('\Ups\Entity\ServiceSummary', $times->ServiceSummary[0]);
$this->assertIsString($times->Disclaimer);
$this->assertTrue(is_string($times->Disclaimer));
$this->assertObjectHasAttribute('PickupDate', $times);
$this->assertObjectHasAttribute('MaximumListSize', $times);
$this->assertObjectHasAttribute('ServiceSummary', $times);
Expand All @@ -102,7 +103,7 @@ public function testRequest()

public function testRequestOddCharacterParse()
{
$tit = new Ups\TimeInTransit();
$tit = new TimeInTransit();
$tit->setRequest($request = new RequestMock(null, '/TimeInTransit/Response2.xml'));
$times = $tit->getTimeInTransit(new TimeInTransitRequest());

Expand All @@ -113,7 +114,7 @@ public function testRequestOddCharacterParse()
$this->assertInstanceOf('\Ups\Entity\ShipmentWeight', $times->ShipmentWeight);
$this->assertInstanceOf('\Ups\Entity\Charges', $times->InvoiceLineTotal);
$this->assertInstanceOf('\Ups\Entity\ServiceSummary', $times->ServiceSummary[0]);
$this->assertIsString($times->Disclaimer);
$this->assertTrue(is_string($times->Disclaimer));
$this->assertObjectHasAttribute('PickupDate', $times);
$this->assertObjectHasAttribute('MaximumListSize', $times);
$this->assertObjectHasAttribute('ServiceSummary', $times);
Expand All @@ -122,12 +123,11 @@ public function testRequestOddCharacterParse()

public function testRequestOddCharacterCheckContent()
{
$tit = new Ups\TimeInTransit();
$tit = new TimeInTransit();
$tit->setRequest($request = new RequestMock(null, '/TimeInTransit/Response2.xml'));
$times = $tit->getTimeInTransit(new TimeInTransitRequest());

// Test response

$this->assertStringContainsString('Ë', $times->TransitTo->PoliticalDivision3);
$this->assertNotFalse(strpos($times->TransitTo->PoliticalDivision3, 'Ë'));
}
}

0 comments on commit df58b29

Please sign in to comment.