forked from cakephp/codeception
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigTrait.php
More file actions
58 lines (50 loc) · 1.66 KB
/
Copy pathConfigTrait.php
File metadata and controls
58 lines (50 loc) · 1.66 KB
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
<?php
namespace Cake\Codeception\Helper;
use Cake\Core\Configure;
trait ConfigTrait
{
/**
* Asserts that a given key (and value) exist in the configuration.
*
* @param string|array $key Configuration key or array of key/values.
* @param mixed $value Value to check for. If `NULL`, checks only key.
*/
public function seeInConfig($key, $value = null)
{
if (is_array($key)) {
array_walk($key, function ($v, $k) {
$this->seeInConfig($k, $v);
});
return;
}
$message = "Could not find the $key config key";
if (is_null($value)) {
$this->assertTrue(Configure::check($key), $message);
return;
}
$message .= ' with ' . json_encode($value);
$this->assertEquals($value, Configure::read($key), $message);
}
/**
* Asserts that a given key (and value) do not exist in the configuration.
*
* @param string|array $key Configuration key or array of key/values.
* @param mixed $value Value to check for. If `NULL`, checks only key.
*/
public function dontSeeInConfig($key, $value = null)
{
if (is_array($key)) {
array_walk($key, function ($v, $k) {
$this->dontSeeInConfig($k, $v);
});
return;
}
$message = "Unexpectedly managed to find the $key config key";
if (is_null($value)) {
$this->assertFalse(Configure::check($key), $message);
return;
}
$message .= ' with ' . json_encode($value);
$this->assertNotEquals($value, Configure::read($key), $message);
}
}