Skip to content

Commit

Permalink
Add term sites tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Sep 3, 2024
1 parent 1f40126 commit ee2f587
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,20 @@ public function test_entry_can_be_created_in_site()
public function test_term_can_be_created_in_site()
{
$term = FactoryTestTermFactory::new()->site('german')->create();
$this->assertSame($term->localizations()->keys()->all(), ['default', 'german']);
$this->assertNotEmpty($term->dataForLocale('default'));
$this->assertNotEmpty($term->dataForLocale('german'));

$term = FactoryTestTermFactory::new()->site('nonexsiting_site')->create();
$this->assertNotContains($term->localizations()->keys()->all(), ['nonexsiting_site']);
$this->assertNotEmpty($term->dataForLocale('default'));
$this->assertEmpty($term->dataForLocale('nonexsiting_site'));

$terms = FactoryTestTermFactory::times(10)->site('random')->create();
$localizations = $terms->map->fileData()->flatMap(fn ($data) => data_get($data, 'localizations', []));
$this->assertNotContains($localizations, ['random']);

$terms = FactoryTestTermFactory::times(10)->site('sequence')->create();
$localizations = $terms->map->fileData()->map(fn ($data) => data_get($data, 'localizations', []));
$this->assertEquals($localizations->filter()->count(), 5);
}

public function test_can_set_publish_state()
Expand Down

0 comments on commit ee2f587

Please sign in to comment.