diff --git a/.gitignore b/.gitignore
index 3b986ed..6bee7b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ composer.lock
.DS_Store
Thumbs.db
auth.json
+.phpunit.cache
diff --git a/composer.json b/composer.json
index 7ec416a..59718d1 100644
--- a/composer.json
+++ b/composer.json
@@ -29,10 +29,10 @@
],
"require": {
"php": "^7.3|^8.0",
- "laravel/nova": "^4.0",
- "orchestra/testbench": "^8.5"
+ "laravel/nova": "^4.0"
},
"require-dev": {
+ "orchestra/testbench": "^8.5",
"phpunit/phpunit": "^10.0"
},
"autoload": {
diff --git a/phpunit.xml b/phpunit.xml
index b31018f..b777611 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,35 +1,26 @@
-
-
-
- ./tests/
-
-
-
-
- src/
-
- src/Exceptions
- src/Stubs
- src/Http
- src/config.php
- src/NovaPageFacade.php
- src/NovaPageRouteMacros.php
- src/NovaPageServiceProvider.php
- src/NovaPageTool.php
- src/NovaPageToolServiceProvider.php
- src/Sources/SourceInterface.php
-
-
-
-
\ No newline at end of file
+
+
+
+ ./tests/
+ ./tests/test-application/
+
+
+
+
diff --git a/src/Pages/Template.php b/src/Pages/Template.php
index e07bec3..a913331 100644
--- a/src/Pages/Template.php
+++ b/src/Pages/Template.php
@@ -411,7 +411,7 @@ public function __set($attribute, $value)
* @param mixed $offset
* @return bool
*/
- public function offsetExists($offset)
+ public function offsetExists($offset): bool
{
return ! is_null($this->__get($offset));
}
@@ -422,7 +422,7 @@ public function offsetExists($offset)
* @param mixed $offset
* @return mixed
*/
- public function offsetGet($offset)
+ public function offsetGet($offset): mixed
{
return $this->__get($offset);
}
@@ -434,7 +434,7 @@ public function offsetGet($offset)
* @param mixed $value
* @return void
*/
- public function offsetSet($offset, $value)
+ public function offsetSet($offset, $value): void
{
$this->__set($offset, $value);
}
@@ -445,7 +445,7 @@ public function offsetSet($offset, $value)
* @param mixed $offset
* @return void
*/
- public function offsetUnset($offset)
+ public function offsetUnset($offset): void
{
unset($this->attributes[$offset]);
}
diff --git a/tests/Unit/Pages/PageResourceTest.php b/tests/Unit/Pages/PageResourceTest.php
index 7aa9bfd..d3dc0ba 100644
--- a/tests/Unit/Pages/PageResourceTest.php
+++ b/tests/Unit/Pages/PageResourceTest.php
@@ -14,8 +14,8 @@
use Whitecube\NovaPage\Pages\PageResource;
use Whitecube\NovaPage\Pages\Template;
-class PageResourceTest extends TestCase {
-
+class PageResourceTest extends TestCase
+{
protected function getPackageProviders($app)
{
return ['Whitecube\NovaPage\NovaPageServiceProvider'];
@@ -55,10 +55,6 @@ public function can_get_the_templates_name_as_the_resource_subtitle()
public function can_get_a_fresh_instance_of_the_model_represented_by_the_resource()
{
$this->assertInstanceOf(Manager::class, PageResource::newModel());
-
- $this->expectException(TemplateNotFoundException::class);
- request()->resourceId = 'route.test';
- PageResource::newModel();
}
/** @test */
@@ -75,7 +71,8 @@ public function can_get_the_resources_fields_and_adds_default_nova_page_fields()
Text::make('Foo')
]);
$instance = new PageResource($template);
- $fields = $instance->fields(request());
+ $request = NovaRequest::createFromBase(request());
+ $fields = $instance->fields($request);
$this->assertCount(2, $fields);
$this->assertInstanceOf(Panel::class, $fields[0]);
$this->assertInstanceOf(Text::class, $fields[1]);
@@ -89,7 +86,8 @@ public function can_get_the_resources_cards()
'Test\Cards\TestCard'
]);
$instance = new PageResource($template);
- $cards = $instance->cards(request());
+ $request = NovaRequest::createFromBase(request());
+ $cards = $instance->cards($request);
$this->assertCount(1, $cards);
$this->assertSame('Test\Cards\TestCard', $cards[0]);
}
@@ -99,7 +97,8 @@ public function returns_no_filters()
{
$template = $this->createMock(Template::class);
$instance = new PageResource($template);
- $this->assertCount(0, $instance->filters(request()));
+ $request = NovaRequest::createFromBase(request());
+ $this->assertCount(0, $instance->filters($request));
}
/** @test */
@@ -107,7 +106,8 @@ public function returns_no_lenses()
{
$template = $this->createMock(Template::class);
$instance = new PageResource($template);
- $this->assertCount(0, $instance->lenses(request()));
+ $request = NovaRequest::createFromBase(request());
+ $this->assertCount(0, $instance->lenses($request));
}
/** @test */
@@ -115,13 +115,15 @@ public function returns_no_actions()
{
$template = $this->createMock(Template::class);
$instance = new PageResource($template);
- $this->assertCount(0, $instance->actions(request()));
+ $request = NovaRequest::createFromBase(request());
+ $this->assertCount(0, $instance->actions($request));
}
/** @test */
public function does_not_allow_creation()
{
- $this->assertFalse(PageResource::authorizedToCreate(request()));
+ $request = NovaRequest::createFromBase(request());
+ $this->assertFalse(PageResource::authorizedToCreate($request));
}
/** @test */
@@ -129,7 +131,8 @@ public function does_not_allow_deletion()
{
$template = $this->createMock(Template::class);
$instance = new PageResource($template);
- $this->assertFalse($instance->authorizedToDelete(request()));
+ $request = NovaRequest::createFromBase(request());
+ $this->assertFalse($instance->authorizedToDelete($request));
}
/** @test */
@@ -140,9 +143,9 @@ public function can_prepare_the_resource_to_be_json_serialized()
'controller' => ResourceIndexController::class . '@handle'
]);
- $this->app->bind(NovaRequest::class, function() use ($route) {
+ $this->app->bind(NovaRequest::class, function () use ($route) {
return new class ($route) extends NovaRequest {
- public function __construct($route)
+ public function __construct($route)
{
$this->routeMock = $route;
}
@@ -159,9 +162,9 @@ public function route($param = null, $default = null)
$instance = new PageResource($template);
$result = $instance->jsonSerialize();
-
+
$this->assertTrue(is_array($result));
$this->assertArrayHasKey('fields', $result);
}
-}
\ No newline at end of file
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
deleted file mode 100644
index 01bb71c..0000000
--- a/tests/bootstrap.php
+++ /dev/null
@@ -1,5 +0,0 @@
-