コード例 #1
0
ファイル: BinderTest.php プロジェクト: pugx/bindto
 /**
  * @test
  * @expectedException \Bindto\Exception\MapperNotFoundException
  */
 public function shouldRaiseException()
 {
     $vars = ['title' => 'yes', 'body' => 'Lorem ipsum dolor sit amet, consectetuer adipi', 'seoTitle' => 'slug of lorem ', 'seoDescription' => 'Lorem ipsum dolor sit amet, consectetuer adipi'];
     $validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator();
     $mapper = new MapperStrategy();
     $binder = new Binder($validator, $mapper);
     $binder->bind($vars, \Bindto\Fixtures\DTOCreatePage::class);
 }
コード例 #2
0
ファイル: ExampleTest.php プロジェクト: agiuliano/Bindto
 /**
  * @test
  */
 public function example()
 {
     $binder = Binder::createSimpleProductionBinder();
     $request = $this->createRequest();
     $bindResult = $binder->bind($request, \Bindto\Fixtures\DTOCreatePage::class);
     $this->assertTrue($bindResult->isValid(), $bindResult->getViolations());
 }
コード例 #3
0
ファイル: ExampleTest.php プロジェクト: pugx/bindto
 /**
  * @test
  */
 public function example()
 {
     $binder = Binder::createSimpleProductionBinder();
     $request = $this->createRequest();
     $bindResult = $binder->bind($request, DTOCreatePage::class);
     $this->assertTrue($bindResult->isValid(), 'bind result should be valid');
     $this->assertEmpty($bindResult->getViolations(), 'violations should be empty');
     $this->assertInstanceOf('Bindto\\Fixtures\\DTOCreatePage', $bindResult->getData(), 'we should get back a DTOCreatePage object');
     $obj = $bindResult->getData();
     $this->assertEquals('my-slug', $obj->title, 'request values should be successfully mapped in resulting object');
 }