|
4 | 4 |
|
5 | 5 | namespace Codeception\Module; |
6 | 6 |
|
7 | | -use Closure; |
8 | 7 | use Codeception\Configuration; |
9 | 8 | use Codeception\Exception\ModuleConfigException; |
10 | 9 | use Codeception\Lib\Connector\Laravel as LaravelConnector; |
|
14 | 13 | use Codeception\Lib\ModuleContainer; |
15 | 14 | use Codeception\Module\Laravel\InteractsWithAuthentication; |
16 | 15 | use Codeception\Module\Laravel\InteractsWithConsole; |
| 16 | +use Codeception\Module\Laravel\InteractsWithContainer; |
17 | 17 | use Codeception\Subscriber\ErrorHandler; |
18 | 18 | use Codeception\TestInterface; |
19 | 19 | use Codeception\Util\ReflectionHelper; |
@@ -131,6 +131,7 @@ class Laravel extends Framework implements ActiveRecord, PartedModule |
131 | 131 | { |
132 | 132 | use InteractsWithAuthentication; |
133 | 133 | use InteractsWithConsole; |
| 134 | + use InteractsWithContainer; |
134 | 135 |
|
135 | 136 | /** |
136 | 137 | * @var Application |
@@ -292,24 +293,6 @@ protected function revertErrorHandler(): void |
292 | 293 | set_error_handler([$handler, 'errorHandler']); |
293 | 294 | } |
294 | 295 |
|
295 | | - /** |
296 | | - * Provides access the Laravel application object. |
297 | | - * |
298 | | - * @return \Illuminate\Contracts\Foundation\Application |
299 | | - */ |
300 | | - public function getApplication() |
301 | | - { |
302 | | - return $this->app; |
303 | | - } |
304 | | - |
305 | | - /** |
306 | | - * @param \Illuminate\Contracts\Foundation\Application $app |
307 | | - */ |
308 | | - public function setApplication($app): void |
309 | | - { |
310 | | - $this->app = $app; |
311 | | - } |
312 | | - |
313 | 296 | /** |
314 | 297 | * Enable Laravel exception handling. |
315 | 298 | * |
@@ -763,32 +746,6 @@ public function seeFormErrorMessage(string $field, $errorMessage = null): void |
763 | 746 | } |
764 | 747 | } |
765 | 748 |
|
766 | | - /** |
767 | | - * Return an instance of a class from the Laravel service container. |
768 | | - * (https://laravel.com/docs/master/container) |
769 | | - * |
770 | | - * ``` php |
771 | | - * <?php |
772 | | - * // In Laravel |
773 | | - * App::bind('foo', function($app) { |
774 | | - * return new FooBar; |
775 | | - * }); |
776 | | - * |
777 | | - * // Then in test |
778 | | - * $service = $I->grabService('foo'); |
779 | | - * |
780 | | - * // Will return an instance of FooBar, also works for singletons. |
781 | | - * ``` |
782 | | - * |
783 | | - * @param string $class |
784 | | - * @return mixed |
785 | | - */ |
786 | | - public function grabService(string $class) |
787 | | - { |
788 | | - return $this->app[$class]; |
789 | | - } |
790 | | - |
791 | | - |
792 | 749 | /** |
793 | 750 | * Inserts record into the database. |
794 | 751 | * If you pass the name of a database table as the first argument, this method returns an integer ID. |
@@ -1231,109 +1188,4 @@ private function buildQuery(string $table, $attributes = []) |
1231 | 1188 | return $query; |
1232 | 1189 | } |
1233 | 1190 |
|
1234 | | - /** |
1235 | | - * Add a binding to the Laravel service container. |
1236 | | - * (https://laravel.com/docs/master/container) |
1237 | | - * |
1238 | | - * ``` php |
1239 | | - * <?php |
1240 | | - * $I->haveBinding('My\Interface', 'My\Implementation'); |
1241 | | - * ``` |
1242 | | - * |
1243 | | - * @param string $abstract |
1244 | | - * @param Closure|string|null $concrete |
1245 | | - * @param bool $shared |
1246 | | - */ |
1247 | | - public function haveBinding(string $abstract, $concrete = null, bool $shared = false): void |
1248 | | - { |
1249 | | - $this->client->haveBinding($abstract, $concrete, $shared); |
1250 | | - } |
1251 | | - |
1252 | | - /** |
1253 | | - * Add a singleton binding to the Laravel service container. |
1254 | | - * (https://laravel.com/docs/master/container) |
1255 | | - * |
1256 | | - * ``` php |
1257 | | - * <?php |
1258 | | - * $I->haveSingleton('App\MyInterface', 'App\MySingleton'); |
1259 | | - * ``` |
1260 | | - * |
1261 | | - * @param string $abstract |
1262 | | - * @param Closure|string|null $concrete |
1263 | | - */ |
1264 | | - public function haveSingleton(string $abstract, $concrete): void |
1265 | | - { |
1266 | | - $this->client->haveBinding($abstract, $concrete, true); |
1267 | | - } |
1268 | | - |
1269 | | - /** |
1270 | | - * Add a contextual binding to the Laravel service container. |
1271 | | - * (https://laravel.com/docs/master/container) |
1272 | | - * |
1273 | | - * ``` php |
1274 | | - * <?php |
1275 | | - * $I->haveContextualBinding('My\Class', '$variable', 'value'); |
1276 | | - * |
1277 | | - * // This is similar to the following in your Laravel application |
1278 | | - * $app->when('My\Class') |
1279 | | - * ->needs('$variable') |
1280 | | - * ->give('value'); |
1281 | | - * ``` |
1282 | | - * |
1283 | | - * @param string $concrete |
1284 | | - * @param string $abstract |
1285 | | - * @param Closure|string $implementation |
1286 | | - */ |
1287 | | - public function haveContextualBinding(string $concrete, string $abstract, $implementation): void |
1288 | | - { |
1289 | | - $this->client->haveContextualBinding($concrete, $abstract, $implementation); |
1290 | | - } |
1291 | | - |
1292 | | - /** |
1293 | | - * Add an instance binding to the Laravel service container. |
1294 | | - * (https://laravel.com/docs/master/container) |
1295 | | - * |
1296 | | - * ``` php |
1297 | | - * <?php |
1298 | | - * $I->haveInstance('App\MyClass', new App\MyClass()); |
1299 | | - * ``` |
1300 | | - * |
1301 | | - * @param string $abstract |
1302 | | - * @param mixed $instance |
1303 | | - */ |
1304 | | - public function haveInstance(string $abstract, $instance): void |
1305 | | - { |
1306 | | - $this->client->haveInstance($abstract, $instance); |
1307 | | - } |
1308 | | - |
1309 | | - /** |
1310 | | - * Register a handler than can be used to modify the Laravel application object after it is initialized. |
1311 | | - * The Laravel application object will be passed as an argument to the handler. |
1312 | | - * |
1313 | | - * ``` php |
1314 | | - * <?php |
1315 | | - * $I->haveApplicationHandler(function($app) { |
1316 | | - * $app->make('config')->set(['test_value' => '10']); |
1317 | | - * }); |
1318 | | - * ``` |
1319 | | - * |
1320 | | - * @param callable $handler |
1321 | | - */ |
1322 | | - public function haveApplicationHandler(callable $handler): void |
1323 | | - { |
1324 | | - $this->client->haveApplicationHandler($handler); |
1325 | | - } |
1326 | | - |
1327 | | - /** |
1328 | | - * Clear the registered application handlers. |
1329 | | - * |
1330 | | - * ``` php |
1331 | | - * <?php |
1332 | | - * $I->clearApplicationHandlers(); |
1333 | | - * ``` |
1334 | | - */ |
1335 | | - public function clearApplicationHandlers(): void |
1336 | | - { |
1337 | | - $this->client->clearApplicationHandlers(); |
1338 | | - } |
1339 | 1191 | } |
0 commit comments