Пример #1
0
 public function testEdgeCases()
 {
     $test = new TestPlugin();
     $this->auth->addPlugin($test);
     $test->setResult(new SplFixedArray());
     // This isn't a valid result.
     try {
         $this->auth->login('u', 'p');
         $this->fail("An invalid result should have triggered an AuthException");
     } catch (AuthException $e) {
         // Expected
     }
     $this->setUp();
     $this->assertTrue($this->auth->addPlugin('Vectorface\\Auth\\Plugin\\SuccessPlugin'));
     $this->auth->addPlugin($test);
     $test->setResult(new Exception("Exception added on purpose by test case."));
     // Causes a log entry and failure.
     $this->assertFalse($this->auth->verify());
     $test->setResult(new AuthException());
     try {
         $this->auth->verify();
         $this->fail("Expected AuthException to be passed up.");
     } catch (AuthException $e) {
         // Expected
     }
     /* Loading by class name should work. */
     $this->assertTrue($this->auth->addPlugin('Vectorface\\Auth\\Plugin\\SuccessPlugin'));
     $this->assertFalse($this->auth->addPlugin(new SplFixedArray()));
     // Fails for obvious reasons.
 }