Skip to content

Commit 5769b1a

Browse files
Update addon testing docs (#1862)
1 parent 46d5872 commit 5769b1a

1 file changed

Lines changed: 46 additions & 2 deletions

File tree

content/collections/pages/testing.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,50 @@ class ExampleTest extends TestCase
8585
}
8686
```
8787

88+
### Update Scripts
89+
90+
To test an [update script](/addons/building-an-addon#update-scripts), import the `RunsUpdateScripts` trait and call `$this->runUpdateScript()` with your script class.
91+
92+
```php
93+
use Statamic\Testing\Concerns\RunsUpdateScripts; // [tl! focus]
94+
95+
class ExampleTest extends TestCase
96+
{
97+
use RunsUpdateScripts; // [tl! focus]
98+
99+
#[Test]
100+
public function it_does_what_it_needs_to_do()
101+
{
102+
$this->runUpdateScript(YourUpdateScript::class); // [tl! focus]
103+
}
104+
105+
// ...
106+
}
107+
```
108+
109+
:::warning
110+
The `RunsUpdateScripts` trait is only available in Statamic v6.3.0 and above. You may need to bump your minimum supported version to use it.
111+
:::
112+
113+
### Inertia.js
114+
115+
The Control Panel is powered by [Inertia.js](https://inertiajs.com), allowing Statamic to render pages as Vue components instead of traditional Blade views.
116+
117+
To assert an Inertia response, use the `->assertInertia()` macro:
118+
119+
```php
120+
use Inertia\Testing\AssertableInertia as Assert;
121+
122+
$this
123+
->get(cp_route('my-addon.index'))
124+
->assertInertia(fn (Assert $page) => $page
125+
->component('my-addon::Foo')
126+
->has('message');
127+
);
128+
```
129+
130+
For more details, see the [Inertia.js testing documentation](https://inertiajs.com/docs/v2/advanced/testing).
131+
88132
## Running Tests
89133

90134
Once you've written some tests, you can run them using `phpunit`:
@@ -125,8 +169,8 @@ jobs:
125169
php_tests:
126170
strategy:
127171
matrix:
128-
php: [8.2, 8.3]
129-
laravel: [10.*, 11.*]
172+
php: [8.3, 8.4, 8.5]
173+
laravel: [12.*, 13.*]
130174
os: [ubuntu-latest]
131175

132176
name: ${{ matrix.php }} - ${{ matrix.laravel }}

0 commit comments

Comments
 (0)