File indexing completed on 2024-12-22 05:37:20

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 
0023 class Local_Verification_WebsiteOwnerTest extends PHPUnit_Framework_TestCase
0024 {
0025 
0026     protected function setUp()
0027     {
0028         require_once APPLICATION_LIB . '/Local/Application.php';
0029 
0030         // Create application, bootstrap, and run
0031         $this->bootstrap = new Local_Application(
0032             APPLICATION_ENV,
0033             Zend_Registry::get('configuration'),
0034             Zend_Registry::get('cache')
0035         );
0036 
0037         parent::setUp(); // TODO: Change the autogenerated stub
0038     }
0039 
0040     protected function tearDown()
0041     {
0042         parent::tearDown(); // TODO: Change the autogenerated stub
0043     }
0044 
0045 
0046     public function testParseDomain()
0047     {
0048         $websiteOwner = new Local_Verification_WebsiteOwner();
0049         $result = $websiteOwner->parseDomain('http://vizzzion.org/blog/2015/09/wall-drawing/');
0050         $this->assertEquals('vizzzion.org', $result);
0051     }
0052 
0053     public function testParseDomainWithHttps()
0054     {
0055         $websiteOwner = new Local_Verification_WebsiteOwner();
0056         $result = $websiteOwner->parseDomain('https://vizzzion.org/blog/2015/09/wall-drawing/');
0057         $this->assertEquals('vizzzion.org', $result);
0058     }
0059 
0060     public function testParseDomainWithWWW()
0061     {
0062         $websiteOwner = new Local_Verification_WebsiteOwner();
0063         $result = $websiteOwner->parseDomain('http://www.vizzzion.org/blog/2015/09/wall-drawing/');
0064         $this->assertEquals('www.vizzzion.org', $result);
0065     }
0066 
0067     public function testParseDomainWithWWWHttps()
0068     {
0069         $websiteOwner = new Local_Verification_WebsiteOwner();
0070         $result = $websiteOwner->parseDomain('https://www.vizzzion.org/blog/2015/09/wall-drawing/');
0071         $this->assertEquals('www.vizzzion.org', $result);
0072     }
0073 
0074     public function testParseDomainWithoutPath()
0075     {
0076         $websiteOwner = new Local_Verification_WebsiteOwner();
0077         $result = $websiteOwner->parseDomain('http://vizzzion.org');
0078         $this->assertEquals('vizzzion.org', $result);
0079     }
0080 
0081     public function testParseDomainWithoutPathWithWWW()
0082     {
0083         $websiteOwner = new Local_Verification_WebsiteOwner();
0084         $result = $websiteOwner->parseDomain('http://www.vizzzion.org');
0085         $this->assertEquals('www.vizzzion.org', $result);
0086     }
0087 
0088     public function testParseDomainWithputPathWithHttps()
0089     {
0090         $websiteOwner = new Local_Verification_WebsiteOwner();
0091         $result = $websiteOwner->parseDomain('https://vizzzion.org');
0092         $this->assertEquals('vizzzion.org', $result);
0093     }
0094 
0095     public function testParseDomainWithoutPathWithTrailingSlash()
0096     {
0097         $websiteOwner = new Local_Verification_WebsiteOwner();
0098         $result = $websiteOwner->parseDomain('http://vizzzion.org/');
0099         $this->assertEquals('vizzzion.org', $result);
0100     }
0101 
0102     public function testParseDomainWithoutProtocol()
0103     {
0104         $websiteOwner = new Local_Verification_WebsiteOwner();
0105         $result = $websiteOwner->parseDomain('vizzzion.org/');
0106         $this->assertEquals('vizzzion.org', $result);
0107     }
0108 
0109 //    public function testParseDomainWithoutProtocolWithSlash()
0110 //    {
0111 //        $websiteOwner = new Local_Verification_WebsiteOwner();
0112 //        $result = $websiteOwner->parseDomain('//vizzzion.org/');
0113 //        $this->assertEquals('vizzzion.org', $result);
0114 //    }
0115 
0116     public function testParseDomainWithUppercaseLetters()
0117     {
0118         $websiteOwner = new Local_Verification_WebsiteOwner();
0119         $result = $websiteOwner->parseDomain('http://vizZzion.org');
0120         $this->assertEquals('vizZzion.org', $result);
0121     }
0122 
0123 }