From dfe360a5b247a9aa1f7d214d5cadb6db009c247b Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Fri, 22 Nov 2024 12:35:33 -0500 Subject: [PATCH] tests --- tests/ContentMigratorTest.php | 28 ++++++++++++++++++++++++++++ tests/MigrateFieldsetTest.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/tests/ContentMigratorTest.php b/tests/ContentMigratorTest.php index 52bac16..147dc55 100644 --- a/tests/ContentMigratorTest.php +++ b/tests/ContentMigratorTest.php @@ -629,6 +629,34 @@ public function it_can_migrate_bards_with_no_sets() $this->assertEquals($expected, $content); } + /** @test */ + public function it_can_migrate_link_it_fields() + { + $content = $this + ->setFields([ + 'url' => ['type' => 'link_it'], + 'asset' => ['type' => 'link_it', 'containers' => ['main']], + 'term' => ['type' => 'link_it', 'taxonomies' => ['tags']], + 'page' => ['type' => 'link_it'], + ]) + ->migrateContent([ + 'url' => ['type' => 'url', 'url' => 'http://example.com'], + 'asset' => ['type' => 'asset', 'asset' => ['/assets/img/coffee-mug.jpg'], 'container' => 'main'], + 'term' => ['type' => 'term', 'term' => ['tags/coffee'], 'taxonomy' => 'tags'], + 'page' => ['type' => 'page', 'page' => ['abc']], + ]); + + $expected = [ + 'url' => ['type' => 'url', 'url' => 'http://example.com'], + 'asset' => ['type' => 'asset', 'asset' => ['main::img/coffee-mug.jpg'], 'container' => 'main'], + 'term' => ['type' => 'term', 'term' => ['tags::coffee'], 'taxonomy' => 'tags'], + 'page' => ['type' => 'entry', 'entry' => ['abc']], + 'blueprint' => 'speaker', + ]; + + $this->assertEquals($expected, $content); + } + /** @test */ public function it_can_migrate_custom_layout() { diff --git a/tests/MigrateFieldsetTest.php b/tests/MigrateFieldsetTest.php index a14947f..b3b0bcf 100644 --- a/tests/MigrateFieldsetTest.php +++ b/tests/MigrateFieldsetTest.php @@ -795,6 +795,41 @@ public function it_migrates_date_field() $this->assertEquals($expected, $fieldset); } + + /** @test */ + public function it_migrates_link_it_field() + { + $fieldset = $this->migrateFieldset([ + 'title' => 'Posts', + 'fields' => [ + 'url' => ['type' => 'link_it'], + 'entries' => ['type' => 'link_it', 'collections' => ['blog', 'products']], + ], + ]); + + $expected = [ + 'title' => 'Posts', + 'fields' => [ + [ + 'handle' => 'url', + 'field' => [ + 'type' => 'link_it', + 'collections' => ['pages'] + ], + ], + [ + 'handle' => 'entries', + 'field' => [ + 'type' => 'link_it', + 'collections' => ['blog', 'products', 'pages'] + ], + ], + ], + ]; + + $this->assertEquals($expected, $fieldset); + } + /** @test */ public function it_migrates_extention_validation() {