File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77use App \Models \Concerns \Threadable ;
88use App \Models \Concerns \Tweetable ;
99use Illuminate \Database \Eloquent \Builder ;
10- use Illuminate \Database \Eloquent \Casts \Attribute ;
1110use Illuminate \Database \Eloquent \Collection ;
1211use Illuminate \Database \Eloquent \Factories \HasFactory ;
1312use Illuminate \Database \Eloquent \Model ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public function definition(): array
1616 return [
1717 'title ' => $ this ->faker ->sentence (),
1818 'slug ' => $ this ->faker ->slug (),
19+ 'excerpt ' => $ this ->faker ->sentences (asText: true ),
1920 'text ' => $ this ->faker ->paragraphs (asText: true ),
2021 'is_published ' => false ,
2122 'published_at ' => null ,
Original file line number Diff line number Diff line change 7878 });
7979 });
8080
81- describe ('excerpt ' , function () {
82- it ('returns limited first line of text ' , function () {
83- $ post = Post::factory ()->create ([
84- 'text ' => 'This is the first line ' .PHP_EOL .'This is the second line ' ,
85- ]);
86-
87- expect ($ post ->excerpt )->toBe ('This is the first line ' );
88- });
89-
90- it ('returns limited text when there is no newline ' , function () {
91- $ longText = str_repeat ('a ' , 300 );
92- $ post = Post::factory ()->create ([
93- 'text ' => $ longText ,
94- ]);
95-
96- expect (mb_strlen ($ post ->excerpt ))->toBe (103 );
97- });
98- });
99-
10081 describe ('scopes ' , function () {
10182 it ('only returns published posts with wherePublished scope ' , function () {
10283 $ published = Post::factory ()->published ()->create ();
You can’t perform that action at this time.
0 commit comments