-
Notifications
You must be signed in to change notification settings - Fork 0
/
puice.feature
213 lines (191 loc) · 7.19 KB
/
puice.feature
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
Feature: Puice
In order to be able to manage Dependencies and Configuration
As a new cool Php Application
I want to have a Framework which take care about these things without a huge overhead and a clear Entrypoint
Scenario: Puice injects Entrypoint with String Dependency(Configuration)
Given the Environment variable 'APP_CONFIG' is set to '/tmp/puice_test.inc.php'
And there is a file '/tmp/puice_test.inc.php' with:
"""
$config->set('string', 'foo', 'bar');
"""
And I have a Class:
"""
class %some_class% extends Puice\Entrypoint
{
public $foo = null;
public function __construct($foo)
{
$this->foo = $foo;
}
}
"""
When I call create on this class
Then I should get 'bar' for the Property 'foo'
Scenario: Shared Dependencies
Given the Environment variable 'APP_CONFIG' is set to '/tmp/puice_global_dependency.inc.php'
And there is a file '/tmp/puice_global_dependency.inc.php' with:
"""
$config->set('Puice\Config', 'config',
$puice->create('Puice\Config\DefaultConfig')
);
"""
And I have a Class:
"""
class %some_class%2
{
public $config = null;
public function __construct(Puice\Config $config)
{
$this->config = $config;
}
}
"""
And I have a Class:
"""
class %some_class% extends Puice\Entrypoint
{
public $config = null;
public $other= null;
public function __construct(Puice\Config $config,
%some_class%2 $other)
{
$this->config = $config;
$this->other = $other;
}
}
"""
When I call create on this class
Then both instances should have the same instance of 'config'
Scenario: Entrypoints do not share dependencies
Given the Environment variable 'APP_CONFIG' is set to '/tmp/puice_global_dependency.inc.php'
And there is a file '/tmp/puice_global_dependency.inc.php' with:
"""
$config->set('Puice\Config', 'config', 'Puice\Config\DefaultConfig');
"""
And I have a Class:
"""
class %some_class% extends Puice\Entrypoint
{
public $config = null;
public function __construct(Puice\Config $config)
{
$this->config = $config;
}
}
"""
When I call create on this class
And create another one
Then both instances should not have the same instance of 'config'
Scenario: Create new Instance for every Dependency
Given the Environment variable 'APP_CONFIG' is set to '/tmp/puice_new_dependency.inc.php'
And there is a file '/tmp/puice_new_dependency.inc.php' with:
"""
$config->set('Puice\Config', 'localConfig',
'Puice\Config\DefaultConfig'
);
"""
And I have a Class:
"""
class %some_class% extends Puice\Entrypoint
{
public $config = null;
public function __construct(Puice\Config $config)
{
$this->config = $config;
}
}
"""
When I call create on this class
And create another one
Then both instances should not have the same instance of 'config'
Scenario: Puice injects itself, without a definition
Given the Environment variable 'APP_CONFIG' is set to '/tmp/puice_factory_test.inc.php'
And there is a file '/tmp/puice_factory_test.inc.php' with:
"""
"""
And I have a Class:
"""
class %some_class% extends Puice\Entrypoint
{
public $puice = null;
public function __construct(Puice $puice)
{
$this->puice = $puice;
}
}
"""
When I call create on this class
Then I should get an Instance of 'Puice' for the Property 'puice'
Scenario: Puice loads config file per EntryPoint
Given the Environment variable 'APP_CONFIG' is set to '/tmp/puice_factory_test.inc.php'
And there is a file '/tmp/puice_factory_test.inc.php' with:
"""
"""
Given the Environment variable '%some_class%_CONFIG' is set to '/tmp/puice_entry_point_test.inc.php'
And there is a file '/tmp/puice_entry_point_test.inc.php' with:
"""
$config->set('string', 'foo', 'mybar');
"""
And I have a Class:
"""
class %some_class% extends Puice\Entrypoint
{
public $foo = null;
public function __construct($foo)
{
$this->foo = $foo;
}
}
"""
When I call create on this class
Then I should get 'mybar' for the Property 'foo'
Scenario: Entrypoint overwrites Path to Applicationconfig
Given there is a file '/tmp/costum_hardcoded.inc.php' with:
"""
$config->set('string', 'foo', 'hardcodedbar');
"""
And I have a Class:
"""
class %some_class% extends Puice\Entrypoint
{
public $foo = null;
public function __construct($foo)
{
$this->foo = $foo;
}
public static function getAppConf()
{
return '/tmp/costum_hardcoded.inc.php';
}
}
"""
When I call create on this class
Then I should get 'hardcodedbar' for the Property 'foo'
Scenario: Entrypoint overwrites function to load entryPoint config from
costum environment variable
Given the Environment variable 'APP_CONFIG' is set to '/tmp/puice_factory_test.inc.php'
And there is a file '/tmp/puice_factory_test.inc.php' with:
"""
"""
Given the Environment variable 'MY_VERY_OWN_DEPS' is set to '/tmp/my_entry_point_test.inc.php'
Given there is a file '/tmp/my_entry_point_test.inc.php' with:
"""
$config->set('string', 'foo', 'envbar');
"""
And I have a Class:
"""
class %some_class% extends Puice\Entrypoint
{
public $foo = null;
public function __construct($foo)
{
$this->foo = $foo;
}
public static function getMyConf()
{
return $_SERVER['MY_VERY_OWN_DEPS'];
}
}
"""
When I call create on this class
Then I should get 'envbar' for the Property 'foo'