From d01ce53dad83484be86fd7f4f0888fbf880a2a9e Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Thu, 27 Feb 2025 14:53:38 -0500 Subject: [PATCH] update tests --- tests/Data/Entries/EntryTest.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/Data/Entries/EntryTest.php b/tests/Data/Entries/EntryTest.php index f99532f921..32b75e19f3 100644 --- a/tests/Data/Entries/EntryTest.php +++ b/tests/Data/Entries/EntryTest.php @@ -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; @@ -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() @@ -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. @@ -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')