public function loadMaster_de(ObjectManager $manager) { $domainObj = new Domains(); $domainObj->setName('master.de'); $domainObj->setType('MASTER'); $manager->persist($domainObj); $manager->flush(); }
/** * @covers SysEleven\PowerDnsBundle\Validator\Constraints\RecordValidator::_validatePtr * @covers SysEleven\PowerDnsBundle\Validator\Constraints\RecordValidator::_checkHostname * @covers SysEleven\PowerDnsBundle\Validator\Constraints\RecordValidator::_checkPtr */ public function testValidatePtr() { /** * @type DomainWorkflow $workflow */ $workflow = $this->container->get('syseleven.pdns.workflow.domains'); /** * @type Domains $domainObj */ $domainObj = $workflow->getRepository()->findOneBy(array()); $recordObj = new Records(); $recordObj->setDomain($domainObj); $recordObj->setName('bogus___.'); $recordObj->setType('PTR'); $recordObj->setContent('1_'); $recordObj->setPrio(-1); $validator = $this->container->get('validator'); $errors = $validator->validate($recordObj); $this->assertCount(3, $errors); $domainObj = new Domains(); $domainObj->setName('1.1.1.in-addr.arpa'); $domainObj->setType('NATIVE'); $domainObj = $workflow->create($domainObj); $recordObj = new Records(); $recordObj->setName('1.1.1.1.in-addr.arpa'); $recordObj->setType('PTR'); $recordObj->setContent('www.example.com'); $recordObj->setDomain($domainObj); $errors = $validator->validate($recordObj); $this->assertCount(0, $errors); }
public function testCreateForceIsDisabled() { try { $domainObj = new Domains(); $domainObj->setName('foo.de'); $this->workflow->create($domainObj, array(), true); } catch (\Exception $e) { $this->assertInstanceOf('SysEleven\\PowerDnsBundle\\Lib\\Exceptions\\ValidationException', $e); /** * @type ValidationException $e */ $this->assertCount(2, $e->getErrors()); $p = array(); /** * @type \Symfony\Component\Validator\ConstraintViolation $error */ foreach ($e->getErrors() as $error) { $p[] = $error->getPropertyPath(); } $this->assertContains('name', $p); $this->assertContains('type', $p); } }