Example #1
0
        function _testEPP ()
        {
			$Domain = $this->Registry->NewDomainInstance();
			$Domain->Name = 'webta' . rand(1000, 9999);
        	
			var_dump($Domain->Name);
			
			////
			// Check domain
        	$ok = $this->Registry->DomainCanBeRegistered($Domain);
			$this->assertTrue($ok, 'Domain available for registration');
        	
			////
			// Create contact
			$Registrant = $this->Registry->NewContactInstanceByGroup('generic');
			$Registrant->SetFieldList($this->contact_data);
			$this->Registry->CreateContact($Registrant);
			$this->assertTrue(true, 'Create contact');

			////
			// Get remote contact
			$RRegistrant = $this->Registry->NewContactInstanceByGroup('generic');
			$RRegistrant->CLID = $Registrant->CLID;
			
			$this->Registry->GetRemoteContact($RRegistrant);
			
			$fields = $Registrant->GetFieldList();
			$rfields = $RRegistrant->GetFieldList();
			
			$this->assertTrue(
				$fields['name'] == $rfields['name'] &&
				$fields['email'] == $rfields['email'] &&
				$fields['voice'] == $rfields['voice'],
				'Get remote contact'
			);
			
			////
			// Create domain
			$Domain->SetContact($Registrant, CONTACT_TYPE::REGISTRANT);
			$Domain->SetContact($Registrant, CONTACT_TYPE::ADMIN);
			$Domain->SetContact($Registrant, CONTACT_TYPE::TECH);
			$Domain->SetContact($Registrant, CONTACT_TYPE::BILLING);
			$Domain->SetNameserverList(array(
				new Nameserver('ns.hostdad.com'),
				new Nameserver('ns2.hostdad.com')
			));
			
			$this->Registry->CreateDomain($Domain, 2);
			$this->assertTrue(true, 'Create domain');
			
			////
			// Create nameservers 
			$ns1 = new NameserverHost('ns1.' . $Domain->GetHostName(), gethostbyname('hostdad.com'));
			$ns2 = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('hostdad.com'));
			
			$this->Registry->CreateNameserverHost($ns1);
			$this->Registry->CreateNameserverHost($ns2);
			
			$this->assertTrue(true, 'Create nameservers');
			
			////
			// Attach nameservers to domain
			$nslist = $Domain->GetNameserverChangelist();
			$nslist->Add($ns1);
			$nslist->Add($ns2);
			
			$this->Registry->UpdateDomainNameservers($Domain, $nslist);
			
			$this->assertTrue(
				count($Domain->GetNameserverList()) == 4,
				'Attach nameservers to domain'
			);
			
			////
			// Create contact and update domain tech contact
			$Tech = $this->Registry->NewContactInstance(CONTACT_TYPE::TECH);
			$Tech->SetFieldList(array_merge($this->contact_data, array(
				'firstname' => 'Nikolas',
				'lastname' => 'Toursky'
			)));
			$this->Registry->CreateContact($Tech);
			
			$this->Registry->UpdateDomainContact($Domain, CONTACT_TYPE::TECH, $Registrant, $Tech);
			$this->assertTrue(true, 'Attach contact to domain');
			
			////
			// Lock domain
			$ok = $this->Registry->LockDomain($Domain);
			$this->assertTrue($ok, 'Lock domain');
			
			////
			// Perform info to verify update
			$RDomain = $this->Registry->NewDomainInstance();
			$RDomain->Name = $Domain->Name;
			
			$RDomain = $this->Registry->GetRemoteDomain($RDomain);
			
			$this->assertTrue(
				$RDomain->Name == $Domain->Name &&
				date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) &&
				date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) &&
				count($RDomain->GetNameserverList()) == count($Domain->GetNameserverList()) &&
				$RDomain->GetContact(CONTACT_TYPE::TECH)->CLID == $Tech->CLID,
				'Get remote domain'
			);
			
			////
			// Unlock domain
			$ok = $this->Registry->UnlockDomain($Domain);
			$this->assertTrue($ok, 'Unlock domain');
			
			////
			// UPDATE one of the name server�s IP Address
			$ns1->IPAddr = gethostbyname('ns.hostdad.com');
			$Resp = $this->Registry->GetModule()->UpdateNameserverHost($ns1);
			$this->assertTrue($Resp->Result, 'Update domain nameserver');
			
			/*
			////
			// Renew domain for 2 years 
			$old_expire_date = $Domain->ExpireDate;
			$this->Registry->RenewDomain($Domain, $extra=array('period' => 2));
			$this->assertTrue(
				date('Ymd', $Domain->ExpireDate) == date('Ymd', strtotime('+2 year', $old_expire_date)),
				'Domain renewal'
			);
			*/
			
			////
			// Remove nameservers from domain 
			$ns_list = $Domain->GetNameserverList();
			$Changes = $Domain->GetNameserverChangelist();
			foreach ($ns_list as $NS)
			{
				$Changes->Remove($NS);
			}
			$this->Registry->UpdateDomainNameservers($Domain, $Changes);
			$this->assertTrue(count($Domain->GetNameserverList()) == 0, 'Remove nameservers from domain');
			
			////
			// Delete nameservers
			foreach ($ns_list as $NS)
			{
				if (preg_match('/'.$Domain->Name.'/', $NS->HostName))
				{
					$this->Registry->DeleteNameserverHost($NS);
				}
			}
			$this->assertTrue(true, 'Delete nameservers');
			
			////
			// Delete domain
			$this->Registry->DeleteDomain($Domain);
			$this->assertTrue(true, 'Delete domain');
			
			////
			// Delete contacts
			$this->Registry->DeleteContact($Registrant);
			$this->Registry->DeleteContact($Tech);
			$this->assertTrue(true, 'Delete contacts');
        }