Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI #24

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading