コード例 #1
0
ファイル: Bus.php プロジェクト: cubiche/cubiche
 /**
  * Bus constructor.
  *
  * @param MiddlewareInterface[] $middlewares
  */
 public function __construct(array $middlewares = array())
 {
     $this->middlewares = new SortedArrayHashMap([], new ReverseComparator(new Comparator()));
     foreach ($middlewares as $priority => $middleware) {
         if (!$middleware instanceof MiddlewareInterface) {
             throw InvalidMiddlewareException::forUnknownValue($middleware);
         }
         $this->addMiddleware($middleware, $priority);
     }
 }
コード例 #2
0
 /**
  * Test forUnknownValue method.
  */
 public function testForUnknownValue()
 {
     $this->given($cause = new \Exception('some cause'))->when($exception = InvalidMiddlewareException::forUnknownValue('foo', $cause))->then->object($exception)->isInstanceOf(InvalidMiddlewareException::class)->integer($exception->getCode())->isEqualTo(0)->object($exception->getPrevious())->isIdenticalTo($cause);
     $this->given($exception = InvalidMiddlewareException::forUnknownValue('bar'))->then->variable($exception->getPrevious())->isNull();
 }