|
3 | 3 | namespace Statamic\Importer\Tests\Transformers; |
4 | 4 |
|
5 | 5 | use PHPUnit\Framework\Attributes\Test; |
| 6 | +use Statamic\Facades\Blueprint; |
6 | 7 | use Statamic\Facades\Collection; |
7 | 8 | use Statamic\Facades\Taxonomy; |
8 | 9 | use Statamic\Facades\Term; |
@@ -52,7 +53,32 @@ public function it_finds_existing_terms() |
52 | 53 |
|
53 | 54 | $output = $transformer->transform('Category One|Category Two|Category Three'); |
54 | 55 |
|
55 | | - $this->assertEquals(['categories::one', 'categories::two', 'categories::three'], $output); |
| 56 | + $this->assertEquals(['one', 'two', 'three'], $output); |
| 57 | + } |
| 58 | + |
| 59 | + #[Test] |
| 60 | + public function it_finds_existing_terms_across_multiple_taxonomies() |
| 61 | + { |
| 62 | + Taxonomy::make('tags')->sites(['default'])->save(); |
| 63 | + |
| 64 | + Term::make()->taxonomy('categories')->slug('one')->set('title', 'Category One')->save(); |
| 65 | + Term::make()->taxonomy('categories')->slug('two')->set('title', 'Category Two')->save(); |
| 66 | + Term::make()->taxonomy('categories')->slug('three')->set('title', 'Category Three')->save(); |
| 67 | + Term::make()->taxonomy('tags')->slug('foo')->set('title', 'Foo')->save(); |
| 68 | + |
| 69 | + $blueprint = Blueprint::find($this->blueprint->fullyQualifiedHandle()); |
| 70 | + $blueprint->ensureField('stuff', ['type' => 'terms', 'taxonomies' => ['categories', 'tags']])->save(); |
| 71 | + |
| 72 | + $transformer = new TermsTransformer( |
| 73 | + import: $this->import, |
| 74 | + blueprint: $blueprint, |
| 75 | + field: $blueprint->field('stuff'), |
| 76 | + config: ['related_field' => 'title'] |
| 77 | + ); |
| 78 | + |
| 79 | + $output = $transformer->transform('Category One|Category Two|Category Three|Foo'); |
| 80 | + |
| 81 | + $this->assertEquals(['categories::one', 'categories::two', 'categories::three', 'tags::foo'], $output); |
56 | 82 | } |
57 | 83 |
|
58 | 84 | #[Test] |
|
0 commit comments