@@ -137,7 +137,7 @@ public function retrieving_data_without_cache_works()
137
137
/** @test */
138
138
public function custom_columns_work_with_db_storage_driver ()
139
139
{
140
- if (config ('tenancy.storage_driver ' ) != 'Stancl\Tenancy\StorageDrivers\DatabaseStorageDriver ' ) {
140
+ if (config ('tenancy.storage_driver ' ) != 'db ' ) {
141
141
$ this ->markTestSkipped ();
142
142
}
143
143
@@ -153,12 +153,38 @@ public function custom_columns_work_with_db_storage_driver()
153
153
'foo ' ,
154
154
]]);
155
155
156
- tenant ()->create (['foo.localhost ' ]);
156
+ tenancy ()->create (['foo.localhost ' ]);
157
157
tenancy ()->init ('foo.localhost ' );
158
158
159
159
tenant ()->put (['foo ' => 'bar ' , 'abc ' => 'xyz ' ]);
160
- $ this ->assertSame (['bar ' , 'xyz ' ], tenant ()->get (['foo ' , 'abc ' ]));
160
+ $ this ->assertSame (['foo ' => ' bar ' , ' abc ' => 'xyz ' ], tenant ()->get (['foo ' , 'abc ' ]));
161
161
162
- $ this ->assertSame ('bar ' , DB ::connection ('central ' )->table ('tenants ' )->where ('id ' , tenant ('id ' ))->first ()->foo );
162
+ $ this ->assertSame ('bar ' , \DB ::connection ('central ' )->table ('tenants ' )->where ('id ' , tenant ('id ' ))->first ()->foo );
163
+ }
164
+
165
+ /** @test */
166
+ public function custom_columns_can_be_used_on_tenant_create ()
167
+ {
168
+ if (config ('tenancy.storage_driver ' ) != 'db ' ) {
169
+ $ this ->markTestSkipped ();
170
+ }
171
+
172
+ tenancy ()->endTenancy ();
173
+
174
+ $ this ->loadMigrationsFrom ([
175
+ '--path ' => __DIR__ . '/Etc ' ,
176
+ '--database ' => 'central ' ,
177
+ ]);
178
+ config (['database.default ' => 'sqlite ' ]); // fix issue caused by loadMigrationsFrom
179
+
180
+ config (['tenancy.storage_drivers.db.custom_columns ' => [
181
+ 'foo ' ,
182
+ ]]);
183
+
184
+ tenancy ()->create (['foo.localhost ' ], ['foo ' => 'bar ' , 'abc ' => 'xyz ' ]);
185
+ tenancy ()->init ('foo.localhost ' );
186
+
187
+ $ this ->assertSame (['foo ' => 'bar ' , 'abc ' => 'xyz ' ], tenant ()->get (['foo ' , 'abc ' ]));
188
+ $ this ->assertSame ('bar ' , \DB ::connection ('central ' )->table ('tenants ' )->where ('id ' , tenant ('id ' ))->first ()->foo );
163
189
}
164
190
}
0 commit comments