Completed
Push — develop ( b85182...537c08 )
by Narcotic
02:54
created

TestUtils::getFullStringFromLog()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
/**
3
 * assorted utils for testing
4
 */
5
6
namespace Graviton\ImportExportTest\Util;
7
8
use Monolog\Handler\TestHandler;
9
use Monolog\Logger;
10
11
/**
12
 * @author   List of contributors <https://github.com/libgraviton/import-export/graphs/contributors>
13
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
14
 * @link     http://swisscom.ch
15
 */
16
class TestUtils
17
{
18
19
    /**
20
     * get a logger for testing
21
     *
22
     * @return Logger
23
     */
24
    public static function getTestingLogger()
25
    {
26
        $logger = new Logger("test");
27
        $handler = new TestHandler();
28
        $logger->pushHandler($handler);
29
        return $logger;
30
    }
31
32
    /**
33
     * gets all lines from the handler in one string
34
     *
35
     * @param TestHandler $handler handler
36
     *
37
     * @return string all lines
38
     */
39
    public static function getFullStringFromLog(TestHandler $handler)
40
    {
41
        $entries = array_map(
42
            function ($val) {
43
                return $val['formatted'];
44
            },
45
            $handler->getRecords()
46
        );
47
        return implode(PHP_EOL, $entries);
48
    }
49
}
50