@@ -93,11 +93,7 @@ public function testTranslationsForCollectionRelationships()
93
93
public function testTranslationsForCollectionDeepRelationships ()
94
94
{
95
95
$ category = Category::with (['content ' , 'content.links ' , 'content.author ' , 'content.author.posts ' ])->get ();
96
-
97
- Post::all ()->each (function ($ post ) {
98
- $ post ->delete ();
99
- });
100
- $ translated = Translator::translate ($ category ->load ())->first ();
96
+ $ translated = Translator::translate ($ category )->first ();
101
97
102
98
$ this ->assertCount (2 , $ translated ->content );
103
99
$ this ->assertCount (2 , $ translated ->content [0 ]->links );
@@ -116,7 +112,7 @@ public function testTranslationsForModelDeepRelationships()
116
112
117
113
$ translated = Translator::translate ($ category );
118
114
119
- $ this ->assertCount (3 , $ translated ->content );
115
+ $ this ->assertCount (4 , $ translated ->content );
120
116
$ this ->assertCount (2 , $ translated ->content [0 ]->links );
121
117
$ this ->assertEquals ('This is what we shall do ' , $ translated ->content [0 ]->trans ('en_GB ' , 'title ' ));
122
118
$ this ->assertEquals ('This is a link ' , $ translated ->content [0 ]->links [0 ]->trans ('en_GB ' , 'title ' ));
@@ -126,35 +122,17 @@ public function testTranslationsForModelDeepRelationships()
126
122
127
123
public function testTranslationsForModelDeepRelationshipsWithMissingRelation ()
128
124
{
129
- $ reviewer = new Reviewer ;
130
-
131
- Link::find (2 )->reviewer ()->save ($ reviewer );
132
-
133
- $ coll = Author::with ([
134
- 'content ' ,
135
- // 'content.category',
136
- 'content.links ' ,
137
- 'content.links.reviewer ' ,
138
- 'content.links.content '
139
-
140
- ])->paginate (1 );
141
-
142
- dd ($ coll );
143
-
144
- Translator::translate ($ coll );
145
- // $collection = Post::with(['category', 'category.content', 'category.content.links', 'category.content.author'])->paginate(1);
146
- //
147
- // dd($collection);
148
- // $translated = Translator::translate($collection);
149
-
150
- // dd($translated->getRelations());
151
-
152
- // $this->assertCount(3, $translated->content);
153
- // $this->assertCount(2, $translated->content[0]->links);
154
- // $this->assertEquals('This is what we shall do', $translated->content[0]->trans('en_GB', 'title'));
155
- // $this->assertEquals('This is a link', $translated->content[0]->links[0]->trans('en_GB', 'title'));
156
- // $this->assertEquals('Author 2 summary', $translated->content[0]->author->trans('en_GB', 'summary'));
157
- // $this->assertEquals('This is a title 3', $translated->content[0]->author->posts[0]->trans('en_GB', 'title'));
125
+ $ links = Link::with (['content ' , 'content.links.reviewer ' , 'content.author ' ])->get ();
126
+ $ translated = Translator::translate ($ links );
127
+
128
+ $ this ->assertCount (11 , $ translated );
129
+ $ link = $ translated ->first ();
130
+ $ this ->assertCount (2 , $ link ->content ->links );
131
+ $ this ->assertEquals ('This is a link ' , $ link ->trans ('en_GB ' , 'title ' ));
132
+ $ this ->assertEquals ('This is what we shall do ' , $ link ->content ->trans ('en_GB ' , 'title ' ));
133
+ $ this ->assertEquals ('This is a link ' ,$ link ->content ->links [0 ]->trans ('en_GB ' , 'title ' ));
134
+ $ this ->assertEquals ('Author 1 summary ' , $ link ->content ->author ->trans ('en_GB ' , 'summary ' ));
135
+ $ this ->assertNull ($ link ->content ->author ->posts [0 ]->trans ('en_GB ' , 'title ' ));
158
136
}
159
137
160
138
/**
@@ -198,6 +176,7 @@ private function createContent()
198
176
$ this ->author2 ->content ()->save ($ this ->content3 = $ this ->category2 ->content ()->save (new Content ));
199
177
$ this ->author2 ->content ()->save ($ this ->content4 = $ this ->category2 ->content ()->save (new Content ));
200
178
$ this ->author2 ->content ()->save ($ this ->content5 = $ this ->category2 ->content ()->save (new Content ));
179
+ $ this ->content6 = $ this ->category2 ->content ()->save (new Content );
201
180
}
202
181
203
182
/**
@@ -215,6 +194,7 @@ private function createLinks()
215
194
$ this ->content4 ->links ()->save (new Link );
216
195
$ this ->content5 ->links ()->save (new Link );
217
196
$ this ->content5 ->links ()->save (new Link );
197
+ $ this ->content6 ->links ()->save (new Link );
218
198
}
219
199
220
200
/**
0 commit comments