コード例 #1
0
 /**
  * Test Logger instantiation
  *
  * Pre-conditions:
  * Case A: Logger instantiated with existing directory
  * Case B: Logger instantiated with non existing directory
  * Case C: Logger instantiated with non existing directory
  * Case D: Logger instantiated with valid level
  * Case E: Logger instantiated with invalid level
  *
  * Post-conditions:
  * Case A: Logger level is 4
  * Case B: RuntimeException not thrown during instantiation with invalid log directory
  * Case C: RuntimeException thrown during log method invocation with invalid log directory
  * Case D: Logger level is 1
  * Case E: InvalidArgumentException thrown
  */
 public function testLoggerInstantiation()
 {
     //Case A
     $l1 = new Slim_Logger($this->logDir);
     $this->assertEquals(4, $l1->getLevel());
     //Case B
     try {
         $l2 = new Slim_Logger('./foo');
     } catch (RuntimeException $e) {
         $this->fail('Instantiating Slim_Logger with bad log directory should only fail when invoking Slim_Logger::log');
     }
     //Case C
     try {
         $l2->warn('Foo');
         $this->fail('Did not catch RuntimeException when invoking Slim_Logger::log with invalid log directory');
     } catch (RuntimeException $e) {
     }
     //Case D
     $l3 = new Slim_Logger($this->logDir, 1);
     $this->assertEquals(1, $l3->getLevel());
     //Case E
     try {
         $l4 = new Slim_Logger($this->logDir, 5);
         $this->fail("Did not catch RuntimeException thrown from Logger with invalid level");
     } catch (InvalidArgumentException $e) {
     }
 }
コード例 #2
0
ファイル: LoggerTest.php プロジェクト: ntdt/Slim
 /**
  * Test Logger instantiation
  *
  * Pre-conditions:
  * Case A: Logger instantiated with existing directory
  * Case B: Logger instantiated with non existing directory
  * Case C: Logger instantiated with valid level
  * Case D: Logger instantiated with invalid level
  *
  * Post-conditions:
  * Case A: Logger created
  * Case B: RuntimeException thrown
  * Case C: Logger created
  * Case D: InvalidArgumentException thrown
  */
 public function testLoggerInstantiation() {
     //Case A
     $l1 = new Slim_Logger('./logs');
     $this->assertEquals(4, $l1->getLevel());
     //Case B
     try {
         $l2 = new Slim_Logger('./foo');
         $this->fail("Did not catch RuntimeException thrown from Logger with non-existant directory");
     } catch ( RuntimeException $e) {}
     //Case C
     $l3 = new Slim_Logger('./logs', 1);
     $this->assertEquals(1, $l3->getLevel());
     //Case D
     try {
         $l4 = new Slim_Logger('./logs', 5);
         $this->fail("Did not catch RuntimeException thrown from Logger with invalid level");
     } catch ( InvalidArgumentException $e) {}
 }