Skip to content
Open
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
12 changes: 7 additions & 5 deletions src/Utils/Testing/EntityList/PendingEntityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@ public function instanceCommand(string $commandKeyOrClassName, int|string $insta

protected function entityListShowField(): ?SharpShowEntityListField
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->parent instanceof PendingShow
? $this->parent->show->getBuiltFields()
if ($this->parent instanceof PendingShow) {
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->parent->show->getBuiltFields()
->first(fn (SharpShowField $field) => $field instanceof SharpShowEntityListField
&& $field->toArray()['entityListKey'] === $this->entityKey
)
: null;
);
}

return null;
}

protected function entityListQueryParams(): array
Expand Down
6 changes: 2 additions & 4 deletions src/Utils/Testing/GeneratesCurrentPageUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

namespace Code16\Sharp\Utils\Testing;

use Code16\Sharp\Utils\Links\BreadcrumbBuilder;

trait GeneratesCurrentPageUrl
{
private function buildCurrentPageUrl(BreadcrumbBuilder $builder): string
private function buildCurrentPageUrl(string $breadcrumbUri): string
{
return url(
sprintf(
'/%s/%s/%s',
sharp()->config()->get('custom_url_segment'),
sharp()->context()->globalFilterUrlSegmentValue(),
$builder->generateUri()
$breadcrumbUri
)
);
}
Expand Down
7 changes: 6 additions & 1 deletion src/Utils/Testing/IsPendingComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ protected function getParentUri(): string
return $this->breadcrumbBuilder($this->parents())->generateUri();
}

protected function getCurrentUri(): string
{
return $this->breadcrumbBuilder([...$this->parents(), $this])->generateUri();
}

protected function getCurrentPageUrlFromParents(): string
{
return $this->buildCurrentPageUrl($this->breadcrumbBuilder([...$this->parents(), $this]));
return $this->buildCurrentPageUrl($this->getCurrentUri());
}

protected function breadcrumbBuilder(array $components): BreadcrumbBuilder
Expand Down
8 changes: 4 additions & 4 deletions src/Utils/Testing/SharpAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function deleteFromSharpList(string $entityClassNameOrKey, mixed $instanc
->withHeader(
SharpBreadcrumb::CURRENT_PAGE_URL_HEADER,
$this->buildCurrentPageUrl(
$this->breadcrumbBuilder($entityKey)
$this->breadcrumbBuilder($entityKey)->generateUri()
),
)
->delete(
Expand Down Expand Up @@ -253,7 +253,7 @@ public function callSharpInstanceCommandFromList(
->withHeader(
SharpBreadcrumb::CURRENT_PAGE_URL_HEADER,
$this->buildCurrentPageUrl(
$this->breadcrumbBuilder($entityKey)
$this->breadcrumbBuilder($entityKey)->generateUri()
),
)
->postJson(
Expand Down Expand Up @@ -284,7 +284,7 @@ public function callSharpInstanceCommandFromShow(
->withHeader(
SharpBreadcrumb::CURRENT_PAGE_URL_HEADER,
$this->buildCurrentPageUrl(
$this->breadcrumbBuilder($entityKey, $instanceId)
$this->breadcrumbBuilder($entityKey, $instanceId)->generateUri()
),
)
->postJson(
Expand Down Expand Up @@ -313,7 +313,7 @@ public function callSharpEntityCommandFromList(
return $this
->withHeader(
SharpBreadcrumb::CURRENT_PAGE_URL_HEADER,
$this->buildCurrentPageUrl($this->breadcrumbBuilder($entityKey))
$this->buildCurrentPageUrl($this->breadcrumbBuilder($entityKey)->generateUri())
)
->postJson(
route('code16.sharp.api.list.command.entity', compact('entityKey', 'commandKey')),
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/Testing/Show/PendingShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public function __construct(
) {
$this->entityKey = app(SharpEntityManager::class)->entityKeyFor($entityKey);
$this->show = app(SharpEntityManager::class)->entityFor($this->entityKey)->getShowOrFail();
sharp()->context()->breadcrumb()->forceRequestSegments(
explode('/', $this->getCurrentUri())
);
}

public function sharpForm(string $entityClassNameOrKey): PendingForm
Expand Down
Loading