Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Feb 27, 2025
1 parent 65598a3 commit d01ce53
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tests/Data/Entries/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use PHPUnit\Framework\Attributes\Test;
use ReflectionClass;
use Statamic\Contracts\Data\Augmentable;
use Statamic\Contracts\Entries\QueryBuilder;
use Statamic\Data\AugmentedCollection;
use Statamic\Entries\AugmentedEntry;
use Statamic\Entries\Collection;
Expand Down Expand Up @@ -1727,7 +1728,12 @@ public function it_gets_file_contents_for_saving_a_localized_entry()
$originEntry = $this->mock(Entry::class);
$originEntry->shouldReceive('id')->andReturn('123');

Facades\Entry::shouldReceive('find')->with('123')->andReturn($originEntry);
$builder = $this->mock(QueryBuilder::class);
$builder->shouldReceive('where')->with('collection', 'test')->andReturnSelf();
$builder->shouldReceive('where')->with('id', 123)->andReturnSelf();
$builder->shouldReceive('first')->andReturn($originEntry);
Facades\Entry::shouldReceive('query')->andReturn($builder);

$originEntry->shouldReceive('values')->andReturn(collect([]));
$originEntry->shouldReceive('blueprint')->andReturn(
$this->mock(Blueprint::class)->shouldReceive('handle')->andReturn('test')->getMock()
Expand Down Expand Up @@ -1805,13 +1811,17 @@ public function the_blueprint_is_not_added_to_the_localized_file_contents()

$originEntry = $this->mock(Entry::class);
$originEntry->shouldReceive('id')->andReturn('123');

Facades\Entry::shouldReceive('find')->with('123')->andReturn($originEntry);
$originEntry->shouldReceive('values')->andReturn(collect([]));
$originEntry->shouldReceive('blueprint')->andReturn(
$this->mock(Blueprint::class)->shouldReceive('handle')->andReturn('another')->getMock()
);

$builder = $this->mock(QueryBuilder::class);
$builder->shouldReceive('where')->with('collection', 'test')->andReturnSelf();
$builder->shouldReceive('where')->with('id', 123)->andReturnSelf();
$builder->shouldReceive('first')->andReturn($originEntry);
Facades\Entry::shouldReceive('query')->andReturn($builder);

$entry = (new Entry)
->collection('test')
->origin('123'); // do not set blueprint.
Expand All @@ -1831,13 +1841,17 @@ public function the_blueprint_is_added_to_the_localized_file_contents_if_explici

$originEntry = $this->mock(Entry::class);
$originEntry->shouldReceive('id')->andReturn('123');

Facades\Entry::shouldReceive('find')->with('123')->andReturn($originEntry);
$originEntry->shouldReceive('values')->andReturn(collect([]));
$originEntry->shouldReceive('blueprint')->andReturn(
$this->mock(Blueprint::class)->shouldReceive('handle')->andReturn('another')->getMock()
);

$builder = $this->mock(QueryBuilder::class);
$builder->shouldReceive('where')->with('collection', 'test')->andReturnSelf();
$builder->shouldReceive('where')->with('id', 123)->andReturnSelf();
$builder->shouldReceive('first')->andReturn($originEntry);
Facades\Entry::shouldReceive('query')->andReturn($builder);

$entry = (new Entry)
->collection('test')
->origin('123')
Expand Down

0 comments on commit d01ce53

Please sign in to comment.