Created
May 18, 2018 05:00
-
-
Save BerezhniyDmitro/fc5b5ac32a15d2046fcf35a8d7bf2a6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests\VO; | |
use App\ValueObject\Domain; | |
use InvalidArgumentException; | |
use PHPUnit_Framework_TestCase; | |
/** | |
* Class DomainTest тестирует VO Domain | |
*/ | |
class DomainTest extends PHPUnit_Framework_TestCase | |
{ | |
/** | |
* Метод тестирует __toString и приведение к строке | |
* | |
* @dataProvider createSuccessDomainDataProvider | |
* @param string $domain домен | |
*/ | |
public function testCreateSuccessDomain($domain) | |
{ | |
$vo = new Domain($domain); | |
$to_string = (string) $vo; | |
$this->assertEquals($to_string, $domain); | |
} | |
/** | |
* Метод тестирует екзепшен при попытке создать домен не валидным | |
* | |
* @dataProvider createFailedDomainDataProvider | |
* @expectedException InvalidArgumentException | |
* @param string $domain домен | |
*/ | |
public function testCreateFailedDomain($domain) | |
{ | |
new Domain($domain); | |
} | |
/** | |
* Метод тестирует успешное создание обьекта | |
* | |
* @dataProvider createSuccessDomainDataProvider | |
* @param string $domain домен | |
*/ | |
public function testGetDomain($domain) | |
{ | |
$vo = new Domain($domain); | |
$this->assertEquals($vo->get_domain_value(), $domain); | |
} | |
/** | |
* Провайдер валидных доменов | |
* | |
* @return array | |
*/ | |
public function createSuccessDomainDataProvider() | |
{ | |
return array( | |
array('http://test.com'), | |
array('https://test.com'), | |
array('https://test.com.ua'), | |
array('http://test.com.ua'), | |
array('http://www.test.com.ua'), | |
array('http://www.test.ua'), | |
array('http://www.test.ua/'), | |
array('https://system4.ua'), | |
array('http://bestcredit.bg'), | |
array('http://test.yuniline.ru'), | |
array('test.yuniline.ru'), | |
array('www.test.yuniline'), | |
array('test.ua'), | |
array('www.test.ua'), | |
array('www.test.com.ua'), | |
array('www.test.com.net'), | |
); | |
} | |
/** | |
* Провайдер невалидных данных | |
* | |
* @return array | |
*/ | |
public function createFailedDomainDataProvider() | |
{ | |
return array( | |
array('bad_url'), | |
array('sadsadsa/dsaasdads'), | |
array('http:/dsd.dsds.ds'), | |
array('hasdsadasds'), | |
array('12345678'), | |
array('http://12345678'), | |
array('https://12345678'), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment