Skip to content

Commit

Permalink
Update CI (#24)
Browse files Browse the repository at this point in the history
* Update CI

* Fix failing tests
  • Loading branch information
ishanvyas22 authored Dec 21, 2023
1 parent 85838cd commit 26eb355
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/check-coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Check Coding Style

on:
push:
branches: [ master ]
branches:
- 'cake5'
- 'cake4'
- 'cake3'
pull_request:
branches: [ master ]
branches:
- '*'

jobs:
check-coding-style:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/run-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Run PHPStan

on:
push:
branches: [ master ]
branches:
- 'cake5'
- 'cake4'
- 'cake3'
pull_request:
branches: [ master ]
branches:
- '*'

jobs:
run-phpstan:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Run tests

on:
push:
branches: [ master ]
branches:
- 'cake5'
- 'cake4'
- 'cake3'
pull_request:
branches: [ master ]
branches:
- '*'

jobs:
run-tests:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ nbproject/*
.vscode
# Sass preprocessor
.sass-cache/
.phpunit.cache/*
18 changes: 14 additions & 4 deletions tests/TestCase/View/InertiaJsonViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,25 @@ public function setUp(): void
{
parent::setUp();

/**
* Prepare request
*/
$request = new ServerRequest();
$response = new Response();

$request = $request
->withParam('controller', 'Pages')
->withParam('action', 'display');
// Set `inertia` detector to test `InertiaJsonView` class
$request->addDetector('inertia', function ($request) {
return true;
});
$request->addDetector('inertia-partial-component', function ($request) {
return false;
});
$request->addDetector('inertia-partial-data', function ($request) {
return false;
});

$this->View = new InertiaJsonView($request, $response);
$this->View = new InertiaJsonView($request, new Response());
}

public function testReturnsJsonResponseWithGivenData()
Expand All @@ -42,7 +52,7 @@ public function testReturnsJsonResponseWithGivenData()
$this->assertArrayHasKey('props', $resultArray);
$this->assertArrayHasKey('user', $resultArray['props']);
$this->assertJsonStringEqualsJsonString(json_encode([
'component' => '/',
'component' => 'Pages/Display',
'url' => 'http://localhost/',
'props' => ['user' => $user],
]), $resultJson);
Expand Down
16 changes: 14 additions & 2 deletions tests/TestCase/View/InertiaWebViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@ public function setUp(): void
parent::setUp();

$request = new ServerRequest();
$response = new Response();
$request = $request
->withParam('controller', '')
->withParam('action', '');
// Set `inertia` detector to test `InertiaJsonView` class
$request->addDetector('inertia', function ($request) {
return true;
});
$request->addDetector('inertia-partial-component', function ($request) {
return false;
});
$request->addDetector('inertia-partial-data', function ($request) {
return false;
});

$this->View = (new ViewBuilder())
->setClassName('Inertia\View\InertiaWebView')
->setOption('_nonInertiaProps', ['one', 'two', 'three'])
->build($request, $response);
->build($request, new Response());
}

public function testRendersDivWithIdAppAttribute()
Expand Down

0 comments on commit 26eb355

Please sign in to comment.