1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
namespace Codeception\Lib\Shared;
/**
* Common functions for Laravel family
*
* @package Codeception\Lib\Shared
*/
trait LaravelCommon
{
/**
* Add a binding to the Laravel service container.
* (https://laravel.com/docs/master/container)
*
* ``` php
* <?php
* $I->haveBinding('My\Interface', 'My\Implementation');
* ?>
* ```
*
* @param $abstract
* @param $concrete
*/
public function haveBinding($abstract, $concrete)
{
$this->client->haveBinding($abstract, $concrete);
}
/**
* Add a singleton binding to the Laravel service container.
* (https://laravel.com/docs/master/container)
*
* ``` php
* <?php
* $I->haveSingleton('My\Interface', 'My\Singleton');
* ?>
* ```
*
* @param $abstract
* @param $concrete
*/
public function haveSingleton($abstract, $concrete)
{
$this->client->haveBinding($abstract, $concrete, true);
}
/**
* Add a contextual binding to the Laravel service container.
* (https://laravel.com/docs/master/container)
*
* ``` php
* <?php
* $I->haveContextualBinding('My\Class', '$variable', 'value');
*
* // This is similar to the following in your Laravel application
* $app->when('My\Class')
* ->needs('$variable')
* ->give('value');
* ?>
* ```
*
* @param $concrete
* @param $abstract
* @param $implementation
*/
public function haveContextualBinding($concrete, $abstract, $implementation)
{
$this->client->haveContextualBinding($concrete, $abstract, $implementation);
}
/**
* Add an instance binding to the Laravel service container.
* (https://laravel.com/docs/master/container)
*
* ``` php
* <?php
* $I->haveInstance('My\Class', new My\Class());
* ?>
* ```
*
* @param $abstract
* @param $instance
*/
public function haveInstance($abstract, $instance)
{
$this->client->haveInstance($abstract, $instance);
}
/**
* Register a handler than can be used to modify the Laravel application object after it is initialized.
* The Laravel application object will be passed as an argument to the handler.
*
* ``` php
* <?php
* $I->haveApplicationHandler(function($app) {
* $app->make('config')->set(['test_value' => '10']);
* });
* ?>
* ```
*
* @param $handler
*/
public function haveApplicationHandler($handler)
{
$this->client->haveApplicationHandler($handler);
}
/**
* Clear the registered application handlers.
*
* ``` php
* <?php
* $I->clearApplicationHandlers();
* ?>
* ```
*
*/
public function clearApplicationHandlers()
{
$this->client->clearApplicationHandlers();
}
}