Skip to content

Commit

Permalink
Merge pull request #6 from codebar-ag/feature-updates
Browse files Browse the repository at this point in the history
Feature Updates
  • Loading branch information
StanBarrows authored Sep 21, 2023
2 parents ba18b17 + d9ff1ce commit ced9e1b
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 123 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: PHPStan

on:
push:
paths:
- '**.php'
- 'phpstan.neon.dist'
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
phpstan:
Expand All @@ -23,4 +23,4 @@ jobs:
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
run: ./vendor/bin/phpstan analyse src --error-format=github
13 changes: 6 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ jobs:
strategy:
fail-fast: true
matrix:
# os: [ ubuntu-latest, windows-latest ]
os: [ ubuntu-latest ]
os: [ ubuntu-latest, windows-latest ]
php: [ 8.2 ]
laravel: [ 10.* ]
#stability: [ prefer-lowest, prefer-stable ]
stability: [ prefer-stable ]
stability: [ prefer-lowest, prefer-stable ]
include:
- laravel: 10.*
testbench: 8.*
Expand Down Expand Up @@ -45,12 +43,13 @@ jobs:
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Set phpunit.xml
run: cp phpunit.xml.dist phpunit.xml

- name: Execute tests
run: vendor/bin/pest
env:
ZAMMAD_URL: ${{ secrets.ZAMMAD_URL }}
ZAMMAD_TOKEN: ${{ secrets.ZAMMAD_TOKEN }}
ZAMMAD_OBJECT_REFERENCE_ERROR_IGNORE: true
FLATFOX_TOKEN: ${{ secrets.FLATFOX_TOKEN }}

- name: Store test reports
uses: actions/upload-artifact@v2
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@
],
"require": {
"php": "^8.2",
"guzzlehttp/guzzle": "^7.2",
"guzzlehttp/guzzle": "^7.5",
"illuminate/contracts": "^10.0",
"sammyjo20/saloon": "^2.6",
"saloonphp/laravel-plugin": "^2.1",
"saloonphp/saloon": "^2.11",
"saloonphp/cache-plugin": "^2.1",
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"laravel/pint": "^1.5",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.4.0",
"pestphp/pest": "^2.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "2.x-dev",
"pestphp/pest-plugin-laravel": "2.x-dev",
"pestphp/pest-plugin-laravel": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ray": "^1.9"
},
"autoload": {
Expand Down
31 changes: 7 additions & 24 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" backupGlobals="false"
bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false"
executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="CodebarAg Test Suite">
<testsuite name="codebar Solutions AG Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
Expand All @@ -39,4 +22,4 @@
<php>
<env name="FLATFOX_TOKEN" value="token"/>
</php>
</phpunit>
</phpunit>
16 changes: 8 additions & 8 deletions src/DTO/Agency.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
class Agency
{
public function __construct(
public string|null $name,
public string|null $name_2,
public string|null $street,
public string|null $zipcode,
public string|null $city,
public string|null $country,
public string|null $logo_url,
public string|null $logo_url_org_logo_m,
public ?string $name,
public ?string $name_2,
public ?string $street,
public ?string $zipcode,
public ?string $city,
public ?string $country,
public ?string $logo_url,
public ?string $logo_url_org_logo_m,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/DTO/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Attribute
{
public function __construct(
public string|null $name,
public ?string $name,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/DTO/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
class Document
{
public function __construct(
public int|null $pk,
public string|null $url,
public int|null $ordering,
public string|null $caption,
public ?int $pk,
public ?string $url,
public ?int $ordering,
public ?string $caption,
) {
}

Expand Down
18 changes: 9 additions & 9 deletions src/DTO/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
class Image
{
public function __construct(
public int|null $pk,
public string|null $caption,
public string|null $url,
public string|null $url_thumb_m,
public string|null $url_listing_search,
public string|null $search_url,
public int|null $ordering,
public int|null $width,
public int|null $height,
public ?int $pk,
public ?string $caption,
public ?string $url,
public ?string $url_thumb_m,
public ?string $url_listing_search,
public ?string $search_url,
public ?int $ordering,
public ?int $width,
public ?int $height,
) {
}

Expand Down
112 changes: 56 additions & 56 deletions src/DTO/Listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,65 @@ class Listing
{
public function __construct(
public int $pk,
public string|null $slug,
public array|null $url,
public string|null $short_url,
public array|null $submit_url,
public string|null $status,
public string|null $offer_type,
public string|null $object_category,
public string|null $object_type,
public string|null $reference,
public string|null $ref_property,
public string|null $ref_house,
public string|null $ref_object,
public string|null $alternative_reference,
public int|null $price_display,
public string|null $price_display_type,
public string|null $price_unit,
public int|null $rent_net,
public int|null $rent_charges,
public int|null $rent_gross,
public string|null $short_title,
public string|null $public_title,
public string|null $pitch_title,
public string|null $description_title,
public string|null $description,
public int|null $surface_living,
public int|null $surface_property,
public int|null $surface_usable,
public int|null $surface_usable_minimum,
public int|null $volume,
public int|null $space_display,
public string|null $number_of_rooms,
public int|null $floor,
public Collection|null $attributes,
public ?string $slug,
public ?array $url,
public ?string $short_url,
public ?array $submit_url,
public ?string $status,
public ?string $offer_type,
public ?string $object_category,
public ?string $object_type,
public ?string $reference,
public ?string $ref_property,
public ?string $ref_house,
public ?string $ref_object,
public ?string $alternative_reference,
public ?int $price_display,
public ?string $price_display_type,
public ?string $price_unit,
public ?int $rent_net,
public ?int $rent_charges,
public ?int $rent_gross,
public ?string $short_title,
public ?string $public_title,
public ?string $pitch_title,
public ?string $description_title,
public ?string $description,
public ?int $surface_living,
public ?int $surface_property,
public ?int $surface_usable,
public ?int $surface_usable_minimum,
public ?int $volume,
public ?int $space_display,
public ?string $number_of_rooms,
public ?int $floor,
public ?Collection $attributes,
public bool $is_furnished,
public bool $is_temporary,
public bool $is_selling_furniture,
public string|null $street,
public int|null $zipcode,
public string|null $city,
public string|null $public_address,
public float|null $latitude,
public float|null $longitude,
public int|null $year_built,
public int|null $year_renovated,
public string|null $moving_date_type,
public Carbon|null $moving_date,
public string|null $video_url,
public string|null $tour_url,
public string|null $website_url,
public string|null $live_viewing_url,
public int|null $cover_image,
public Collection|null $images,
public Collection|null $documents,
public Agency|null $agency,
public ?string $street,
public ?int $zipcode,
public ?string $city,
public ?string $public_address,
public ?float $latitude,
public ?float $longitude,
public ?int $year_built,
public ?int $year_renovated,
public ?string $moving_date_type,
public ?Carbon $moving_date,
public ?string $video_url,
public ?string $tour_url,
public ?string $website_url,
public ?string $live_viewing_url,
public ?int $cover_image,
public ?Collection $images,
public ?Collection $documents,
public ?Agency $agency,
public bool $reserved,
public string|null $rent_title,
public int|null $livingspace,
public Carbon|null $published,
public Carbon|null $created,
public ?string $rent_title,
public ?int $livingspace,
public ?Carbon $published,
public ?Carbon $created,
) {
}

Expand All @@ -84,7 +84,7 @@ public static function fromJson(array $data): self
pk: Arr::get($data, 'pk'),
slug: Arr::get($data, 'slug'),
url: [
'de' => Str::replace('/en/', '/de/', $url),
'de' => Str::replace('/en/flat/', '/de/wohnung/', $url),
'en' => $url,
'fr' => Str::replace('/en/', '/fr/', $url),
'it' => Str::replace('/en/', '/it/', $url),
Expand Down
4 changes: 2 additions & 2 deletions src/Requests/GetPublicListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function resolveEndpoint(): string

public function __construct(
protected string $identifier,
protected string|null $expand = null,
protected ?string $expand = null,
) {
}

Expand All @@ -47,7 +47,7 @@ public function createDtoFromResponse(Response $response): mixed
protected function defaultConfig(): array
{
return [
'timeout' => config('flatfox.caching', 15),
'timeout' => config('flatfox.timeout', 15),
];
}

Expand Down
6 changes: 3 additions & 3 deletions src/Response/PublicListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ final class PublicListing
{
public function __construct(
public int $count,
public string|null $next,
public string|null $previous,
public Collection|null $results,
public ?string $next,
public ?string $previous,
public ?Collection $results,
) {
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Feature/GetPublicListingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
namespace CodebarAg\FlatFox\Tests\Feature;

use CodebarAg\Flatfox\Requests\GetPublicListing;
use Saloon\Http\Faking\MockClient;
use Saloon\Http\Faking\MockResponse;

it('get public listing', function () {

$mockClient = new MockClient([
GetPublicListing::class => MockResponse::fixture('get-public-listing-request'),
]);

$request = new GetPublicListing(142, '&expand=documents&expand=images');
$request->withMockClient($mockClient);

$response = $request->send();

$mockClient->assertSent(GetPublicListing::class);

expect($response->status())->toBe(200)
->and($response->dto())->not()->toBeEmpty();
})
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/Saloon/get-public-listing-request.json

Large diffs are not rendered by default.

0 comments on commit ced9e1b

Please sign in to comment.