/** * @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); }
/** * @test */ public function example() { $binder = Binder::createSimpleProductionBinder(); $request = $this->createRequest(); $bindResult = $binder->bind($request, \Bindto\Fixtures\DTOCreatePage::class); $this->assertTrue($bindResult->isValid(), $bindResult->getViolations()); }
/** * @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'); }