@@ -82,6 +82,7 @@ public function test_it_should_load_metadata_for_mappings_passed_as_constructor_
82
82
StubEntity::class,
83
83
new ClassMetadataInfo (StubEntity::class)
84
84
);
85
+
85
86
$ this ->assertInstanceOf (
86
87
EntityMapper::class,
87
88
$ driver ->getMappers ()->getMapperFor (StubEntity::class)
@@ -91,6 +92,7 @@ public function test_it_should_load_metadata_for_mappings_passed_as_constructor_
91
92
StubEmbeddable::class,
92
93
new ClassMetadataInfo (StubEmbeddable::class)
93
94
);
95
+
94
96
$ this ->assertInstanceOf (
95
97
EmbeddableMapper::class,
96
98
$ driver ->getMappers ()->getMapperFor (StubEmbeddable::class)
@@ -100,6 +102,7 @@ public function test_it_should_load_metadata_for_mappings_passed_as_constructor_
100
102
StubMappedSuperClass::class,
101
103
new ClassMetadataInfo (StubMappedSuperClass::class)
102
104
);
105
+
103
106
$ this ->assertInstanceOf (
104
107
MappedSuperClassMapper::class,
105
108
$ driver ->getMappers ()->getMapperFor (StubMappedSuperClass::class)
@@ -126,9 +129,96 @@ public function test_can_add_array_of_new_mappings()
126
129
);
127
130
}
128
131
132
+ public function test_can_load_mappings_through_file_path ()
133
+ {
134
+ $ driver = new FluentDriver ([], [__DIR__ . '/ ' . 'Stubs/Mappings ' ]);
135
+
136
+ $ this ->assertContains (
137
+ StubEntity::class,
138
+ $ driver ->getAllClassNames ()
139
+ );
140
+
141
+ $ this ->assertContains (
142
+ StubEmbeddable::class,
143
+ $ driver ->getAllClassNames ()
144
+ );
145
+
146
+ $ this ->assertContains (
147
+ StubMappedSuperClass::class,
148
+ $ driver ->getAllClassNames ()
149
+ );
150
+
151
+ $ driver ->loadMetadataForClass (
152
+ StubEntity::class,
153
+ new ClassMetadataInfo (StubEntity::class)
154
+ );
155
+
156
+ $ this ->assertInstanceOf (
157
+ EntityMapper::class,
158
+ $ driver ->getMappers ()->getMapperFor (StubEntity::class)
159
+ );
160
+
161
+ $ driver ->loadMetadataForClass (
162
+ StubEmbeddable::class,
163
+ new ClassMetadataInfo (StubEmbeddable::class)
164
+ );
165
+
166
+ $ this ->assertInstanceOf (
167
+ EmbeddableMapper::class,
168
+ $ driver ->getMappers ()->getMapperFor (StubEmbeddable::class)
169
+ );
170
+
171
+ $ driver ->loadMetadataForClass (
172
+ StubMappedSuperClass::class,
173
+ new ClassMetadataInfo (StubMappedSuperClass::class)
174
+ );
175
+
176
+ $ this ->assertInstanceOf (
177
+ MappedSuperClassMapper::class,
178
+ $ driver ->getMappers ()->getMapperFor (StubMappedSuperClass::class)
179
+ );
180
+ }
181
+
182
+ public function test_can_load_paths ()
183
+ {
184
+ $ driver = new FluentDriver ();
185
+ $ driver ->loadPaths ([__DIR__ . '/ ' . 'Stubs/Mappings ' ]);
186
+
187
+ $ this ->assertContains (
188
+ StubEntity::class,
189
+ $ driver ->getAllClassNames ()
190
+ );
191
+
192
+ $ this ->assertContains (
193
+ StubEmbeddable::class,
194
+ $ driver ->getAllClassNames ()
195
+ );
196
+
197
+ $ this ->assertContains (
198
+ StubMappedSuperClass::class,
199
+ $ driver ->getAllClassNames ()
200
+ );
201
+ }
202
+
203
+ public function test_loading_by_paths_throws_exception_if_dir_not_exists ()
204
+ {
205
+ $ folder = __DIR__ . '/ ' . 'Stubs/non-existing-folder ' ;
206
+
207
+ $ this ->setExpectedException (
208
+ MappingException::class,
209
+ 'File mapping drivers must have a valid directory path, however the given path [ ' . $ folder . '] seems to be incorrect! '
210
+ );
211
+
212
+ $ driver = new FluentDriver ();
213
+ $ driver ->loadPaths ([$ folder ]);
214
+
215
+ $ driver ->getAllClassNames ();
216
+ }
217
+
129
218
public function test_the_given_mapping_class_should_exist ()
130
219
{
131
- $ this ->setExpectedException (\InvalidArgumentException::class, 'Mapping class [Tests\DoesnExist] does not exist ' );
220
+ $ this ->setExpectedException (\InvalidArgumentException::class,
221
+ 'Mapping class [Tests\DoesnExist] does not exist ' );
132
222
133
223
$ driver = new FluentDriver ;
134
224
@@ -139,7 +229,8 @@ public function test_the_given_mapping_class_should_exist()
139
229
140
230
public function test_the_given_mapping_class_should_implement_mapping ()
141
231
{
142
- $ this ->setExpectedException (\InvalidArgumentException::class, 'Mapping class [Tests\Stubs\Entities\StubEntity] should implement LaravelDoctrine\Fluent\Mapping ' );
232
+ $ this ->setExpectedException (\InvalidArgumentException::class,
233
+ 'Mapping class [Tests\Stubs\Entities\StubEntity] should implement LaravelDoctrine\Fluent\Mapping ' );
143
234
144
235
$ driver = new FluentDriver ;
145
236
0 commit comments