diff --git a/src/SEOTools/JsonLdMulti.php b/src/SEOTools/JsonLdMulti.php index 1350020..4bc2f04 100644 --- a/src/SEOTools/JsonLdMulti.php +++ b/src/SEOTools/JsonLdMulti.php @@ -47,11 +47,9 @@ public function __construct(array $defaultJsonLdData = []) */ public function generate($minify = false) { - if (count($this->list) > 1) { - return array_reduce($this->list, function (string $output, JsonLd $jsonLd) { - return $output . (! $jsonLd->isEmpty() ? $jsonLd->generate() : ''); - }, ''); - } + return array_reduce($this->list, function (string $output, JsonLd $jsonLd) { + return $output . (! $jsonLd->isEmpty() ? $jsonLd->generate() : ''); + }, ''); } /** diff --git a/tests/SEOTools/JsonLdMultiTest.php b/tests/SEOTools/JsonLdMultiTest.php index 3957d0c..0f69c25 100644 --- a/tests/SEOTools/JsonLdMultiTest.php +++ b/tests/SEOTools/JsonLdMultiTest.php @@ -30,6 +30,15 @@ protected function setUp(): void $this->jsonLdMulti->newJsonLd(); } + public function test_single_instance() + { + $jsonLdSingle = new JsonLdMulti(); + + $expected = '' . $this->defaultJsonLdHtml . ''; + + $this->assertEquals($this->makeDomDocument($expected)->C14N(), $this->makeDomDocument($jsonLdSingle->generate())->C14N()); + } + public function test_set_title() { $this->jsonLdMulti->setTitle('Kamehamehaaaaaaaa');