Skip to content

Commit

Permalink
Rename ViewFixture.javaScriptDeclarations() to JavaScriptFixture.scri…
Browse files Browse the repository at this point in the history
…ptDeclarations()
  • Loading branch information
danon committed Jan 25, 2024
1 parent 7be909a commit 6e99d6e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Tests\Unit\BaseFixture\View;

class ViewFixture
class JavaScriptFixture
{
private ViewDom $dom;

Expand All @@ -13,7 +13,7 @@ public function __construct(string $html)
/**
* @return Script[]
*/
public function javaScriptDeclarations(): array
public function scriptDeclarations(): array
{
$declarations = [];
foreach ($this->scriptTags() as $script) {
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Seo/Schema/Fixture/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
namespace Tests\Unit\Seo\Schema\Fixture;

use Tests\Unit\BaseFixture\Server;
use Tests\Unit\BaseFixture\View\ViewFixture;
use Tests\Unit\BaseFixture\View\JavaScriptFixture;

trait Schema
{
use Server\Http;

function schema(string $uri, string $type): ?array
{
return $this->firstSchema(new ViewFixture($this->viewHtml($uri)), $type);
return $this->firstSchema(new JavaScriptFixture($this->viewHtml($uri)), $type);
}

function viewHtml(string $uri): string
{
return $this->server->get($uri)->assertSuccessful()->content();
}

function firstSchema(ViewFixture $viewFixture, string $type): ?array
function firstSchema(JavaScriptFixture $viewFixture, string $type): ?array
{
foreach ($this->schemaObjects($viewFixture) as $schema) {
if ($schema['@type'] === $type) {
Expand All @@ -28,9 +28,9 @@ function firstSchema(ViewFixture $viewFixture, string $type): ?array
return null;
}

function schemaObjects(ViewFixture $viewFixture): iterable
function schemaObjects(JavaScriptFixture $viewFixture): iterable
{
foreach ($viewFixture->javaScriptDeclarations() as $declaration) {
foreach ($viewFixture->scriptDeclarations() as $declaration) {
if ($declaration->type() === 'application/ld+json') {
yield $declaration->object();
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Topic/Fixture/SpaView.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
namespace Tests\Unit\Topic\Fixture;

use Tests\Unit\BaseFixture\View\ViewFixture;
use Tests\Unit\BaseFixture\View\JavaScriptFixture;

class SpaView
{
private ViewFixture $view;
private JavaScriptFixture $view;

public function __construct(private string $html)
{
$this->view = new ViewFixture($this->html);
$this->view = new JavaScriptFixture($this->html);
}

public function jsVariables(): array
Expand All @@ -26,7 +26,7 @@ public function jsVariables(): array

private function javaScriptVariableDeclarations(): \Iterator
{
foreach ($this->view->javaScriptDeclarations() as $script) {
foreach ($this->view->scriptDeclarations() as $script) {
if ($script->type() === 'application/ld+json') {
continue;
}
Expand Down

0 comments on commit 6e99d6e

Please sign in to comment.