File: StatusTest.php

package info (click to toggle)
php-composer-xdebug-handler 1.4.5-1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 264 kB
  • sloc: php: 1,412; makefile: 16
file content (56 lines) | stat: -rw-r--r-- 1,424 bytes parent folder | download
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
<?php

/*
 * This file is part of composer/xdebug-handler.
 *
 * (c) Composer <https://github.com/composer>
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Composer\XdebugHandler;

use Composer\XdebugHandler\Helpers\BaseTestCase;
use Composer\XdebugHandler\Helpers\Logger;
use Composer\XdebugHandler\Mocks\CoreMock;
use Psr\Log\LogLevel;

/**
 * We use PHP_BINARY which only became available in PHP 5.4
 *
 * @requires PHP 5.4
 */
class StatusTest extends BaseTestCase
{
    public function testSetLoggerProvidesOutput()
    {
        $loaded = true;

        $logger = new Logger();
        $settings = array('setLogger' => array($logger));

        $xdebug = CoreMock::createAndCheck($loaded, null, $settings);
        $this->checkRestart($xdebug);

        $output = $logger->getOutput();
        $this->assertNotEmpty($output);
        $this->checkStatusOutput($output);
    }

    /**
     * Assertions to check the status message and logging formats
     *
     * @param array $output
     */
    protected function checkStatusOutput(array $output)
    {
        $levels = array(LogLevel::DEBUG, LogLevel::WARNING);

        foreach ($output as $record) {
            $this->assertCount(3, $record);
            $this->assertContains($record[0], $levels);
            $this->assertCount(0, $record[2]);
        }
    }
}