<?php
namespace OSInet\Class_Grapher;

require_once 'OSInet/Class_Grapher/Logger.php';
require_once 'PHPUnit/Framework/TestCase.php';

/**
 * Logger test case.
 */
class LoggerTest extends \PHPUnit_Framework_TestCase {

  /**
   *
   * @var Logger
   */
  private $Logger;

  /**
   * Prepares the environment before running a test.
   */
  protected function setUp() {
    parent::setUp();
    $this->Logger = new Logger();
  }

  /**
   * Cleans up the environment after running a test.
   */
  protected function tearDown() {
    $this->Logger = null;
    parent::tearDown();
  }

  /**
   * Tests Logger->__construct()
   */
  public function test__construct() {
    $this->Logger->__construct(LOG_DEBUG);
    $this->assertEquals($this->Logger->debugLevel(), LOG_DEBUG);

    $this->Logger->__construct(LOG_EMERG - 1);
    $this->assertEquals($this->Logger->debugLevel(), LOG_EMERG);

    $this->Logger->__construct(LOG_DEBUG + 1);
    $this->assertEquals($this->Logger->debugLevel(), LOG_DEBUG);

    $this->Logger->__construct();
    $this->assertEquals($this->Logger->debugLevel(), LOG_WARNING);
  }

  public function testDebugLevel() {
    $this->assertEquals(LOG_WARNING, $this->Logger->debugLevel());

    $level = $this->Logger->debugLevel(LOG_EMERG);
    $this->assertEquals(LOG_WARNING, $level);

    $level = $this->Logger->debugLevel();
    $this->assertEquals(LOG_EMERG, $level);
  }

  /**
   * Tests Logger->debug()
   */
  public function testDebug() {
    $this->markTestSkipped("STDERR capture not available. Cannot test.");
  }
}