Example #1
0
 /**
  * Displays a form to create a new Domain entity.
  *
  * @Route("/new", name="config_domain_new")
  * @Template()
  */
 public function newAction()
 {
     $entity = new Domain();
     $entity->setPath('(auto)');
     $form = $this->createForm(new DomainType(), $entity);
     return array('entity' => $entity, 'form' => $form->createView());
 }
 /**
  * Provides protections.
  *
  * @return array
  */
 public function dataProvider()
 {
     $domain = new Domain();
     $domain->setPath('/var/www/test.de');
     $protection = new Protection($domain);
     $user1 = new ProtectionUser($domain, $protection);
     $user2 = new ProtectionUser($domain, $protection);
     $user1->setUsername('test1')->setPassword('pw1');
     $user2->setUsername('test2')->setPassword('pw2');
     $collection = new ArrayCollection(array($user1, $user2));
     $protection->setProtectionuser($collection)->setId(1)->setPath('/var/www/test.de/htdocs/test');
     return array(array($protection));
 }
 /**
  * Test createAuthUserFile().
  */
 public function testCreateAuthUserFile()
 {
     $fs = new Filesystem();
     $fs->mkdir(sys_get_temp_dir() . '/conf');
     $domain = new Domain();
     $protection = new Protection($domain);
     $protectionuser = new ProtectionUser($domain, $protection);
     $domain->setPath(sys_get_temp_dir());
     $protection->setId(1)->setProtectionuser(new ArrayCollection(array($protectionuser)));
     $protectionuser->setUsername('test')->setPassword('tester')->setProtection($protection);
     $this->getService()->createAuthUserFile($protection);
     $this->assertFileExists(sys_get_temp_dir() . '/conf/authuser_1.passwd');
 }
Example #4
0
 /**
  * Test getDirectoryOptions().
  */
 public function testGetDirectoryOptions()
 {
     $domain = new Domain();
     $po1 = new PathOption($domain);
     $po2 = new PathOption($domain);
     $po3 = new PathOption($domain);
     $protection1 = new Protection($domain);
     $protection2 = new Protection($domain);
     $protection3 = new Protection($domain);
     $domain->setPath('/var/www/domain.de')->setWebroot('htdocs/test');
     $domain->getPathoption()->add($po1);
     $domain->getPathoption()->add($po2);
     $domain->getPathoption()->add($po3);
     $domain->getProtection()->add($protection1);
     $domain->getProtection()->add($protection2);
     $domain->getProtection()->add($protection3);
     $po1->setPath('htdocs/test/subfolder');
     $po2->setPath('htdocs');
     $po3->setPath('htdocs/test');
     $protection1->setPath('htdocs');
     $protection2->setPath('htdocs/test/subfolder2');
     $protection3->setPath('htdocs/test');
     $vhost = new Vhost();
     $vhost->setDomain($domain);
     $options = $vhost->getDirectoryOptions();
     $this->assertCount(2, $options);
     $testPo = false;
     $testProt = false;
     foreach ($options as $optset) {
         if ($optset['pathoption'] !== null) {
             $this->assertEquals($po1, $optset['pathoption']);
             $testPo = true;
         }
         if ($optset['protection'] !== null) {
             $this->assertEquals($protection2, $optset['protection']);
             $testProt = true;
         }
     }
     $this->assertTrue($testPo);
     $this->assertTrue($testProt);
 }