Completed
Push — master ( 8034fc...198927 )
by Cheren
02:28
created

TestCase::_getStrArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
/**
3
 * CakeCMS Core
4
 *
5
 * This file is part of the of the simple cms based on CakePHP 3.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package   Core
10
 * @license   MIT
11
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
12
 * @link      https://github.com/CakeCMS/Core".
13
 * @author    Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace Core\TestSuite;
17
18
use Core\Plugin;
19
use JBZoo\Utils\Str;
20
use Cake\Cache\Cache;
21
use Cake\TestSuite\TestCase as CakeTestCase;
22
23
/**
24
 * Class TestCase
25
 *
26
 * @package Core\TestSuite
27
 */
28
class TestCase extends CakeTestCase
29
{
30
31
    /**
32
     * Default plugin name.
33
     *
34
     * @var string
35
     */
36
    protected $_plugin = 'Core';
37
38
    /**
39
     * Setup the test case, backup the static object values so they can be restored.
40
     * Specifically backs up the contents of Configure and paths in App if they have
41
     * not already been backed up.
42
     *
43
     * @return void
44
     */
45
    public function setUp()
46
    {
47
        parent::setUp();
48
49
        $options = [
50
            'path' => ROOT . DS,
51
            'bootstrap' => true,
52
            'routes' => true,
53
        ];
54
55
        if ($this->_plugin !== 'Core') {
56
            unset($options['path']);
57
            $options['autoload'] = true;
58
        }
59
60
        Plugin::load($this->_plugin, $options);
61
        Plugin::routes($this->_plugin);
62
    }
63
64
    /**
65
     * Clears the state used for requests.
66
     *
67
     * @return void
68
     */
69
    public function tearDown()
70
    {
71
        parent::tearDown();
72
        Plugin::unload($this->_plugin);
73
        Cache::drop('test_cached');
74
    }
75
76
    /**
77
     * @param string $string
78
     * @return array
79
     */
80
    protected function _getStrArray($string)
81
    {
82
        $output  = [];
83
        $details = explode("\n", $string);
84
        foreach ($details as $string) {
85
            $string   = Str::trim($string);
86
            $output[] = $string;
87
        }
88
89
        return $output;
90
    }
91
}
92