Пример #1
0
 public function __construct($viewPath)
 {
     $this->binders = new ModelBinderRegistry();
     $this->binders->addBinder('Tmont\\Facilius\\Models\\UploadedFile', new UploadedFileModelBinder());
     $this->response = new Response();
     $this->viewPath = $viewPath;
 }
Пример #2
0
 public function testExecuteActionWithParameters()
 {
     $controller = new FakeController1();
     $binder = $this->getMock('\\Tmont\\Facilius\\ModelBinder', array('bindModel'));
     $binder->expects($this->at(0))->method('bindModel')->will($this->returnCallback(function (BindingContext $context) {
         PHPUnit_Framework_Assert::assertEquals('foo', $context->name);
         PHPUnit_Framework_Assert::assertEquals('string', $context->type);
         PHPUnit_Framework_Assert::assertSame(array('foo' => 'baz', 'bar' => 'bat'), $context->values);
         return 'foo';
     }));
     $binder->expects($this->at(1))->method('bindModel')->will($this->returnCallback(function (BindingContext $context) {
         PHPUnit_Framework_Assert::assertEquals('bar', $context->name);
         PHPUnit_Framework_Assert::assertEquals('array', $context->type);
         PHPUnit_Framework_Assert::assertSame(array('foo' => 'baz', 'bar' => 'bat'), $context->values);
         return array();
     }));
     $binders = new ModelBinderRegistry();
     $binders->setDefaultBinder($binder);
     $context = new ActionExecutionContext(new Request(array('foo' => 'bar'), array('foo' => 'baz', 'bar' => 'bat')), array(), array(), new RouteMatch(new Route(''), array()), $binders, 'hasParams');
     $result = $controller->execute($context);
     self::assertNotNull($result);
     self::assertInstanceOf('\\Tmont\\Facilius\\ContentResult', $result);
     self::assertEquals('has params was executed', $result->getData());
 }