Renamed TempMailBuster to Validator

This commit is contained in:
ErickSkrauch 2016-04-29 01:55:57 +03:00
parent 7b82e48cdd
commit fdcd0ab16b
2 changed files with 17 additions and 17 deletions

View File

@ -1,7 +1,7 @@
<?php
namespace Ely\TempMailBuster;
class TempMailBuster
class Validator
{
/**
* @var StorageInterface

View File

@ -1,31 +1,31 @@
<?php
namespace Ely\TempMailBuster;
class TempMailBusterTest extends \PHPUnit_Framework_TestCase
class ValidatorTest extends \PHPUnit_Framework_TestCase
{
public function testValidate()
{
$object = new TempMailBuster(new Storage());
$object = new Validator(new Storage());
$this->assertTrue($object->validate('notch@mojang.com'));
$object = new TempMailBuster(new Storage());
$object = new Validator(new Storage());
$object->whitelistMode();
$this->assertFalse($object->validate('notch@mojang.com'));
$object = new TempMailBuster(new Storage(['mojang\.com']));
$object = new Validator(new Storage(['mojang\.com']));
$this->assertFalse($object->validate('notch@mojang.com'));
$this->assertTrue($object->validate('erickskrauch@ely.by'));
$object = new TempMailBuster(new Storage(['gmail\.com']));
$object = new Validator(new Storage(['gmail\.com']));
$object->whitelistMode();
$this->assertFalse($object->validate('team@ely.by'));
$this->assertTrue($object->validate('erickskrauch@gmail.com'));
$object = new TempMailBuster(new Storage(['mojang\.com', 'ely\.by']), new Storage(['ely\.by']));
$object = new Validator(new Storage(['mojang\.com', 'ely\.by']), new Storage(['ely\.by']));
$this->assertFalse($object->validate('notch@mojang.com'));
$this->assertTrue($object->validate('team@ely.by'));
$object = new TempMailBuster(new Storage(['gmail\.com', 'mail\.ru']), new Storage(['mail\.ru']));
$object = new Validator(new Storage(['gmail\.com', 'mail\.ru']), new Storage(['mail\.ru']));
$object->whitelistMode();
$this->assertTrue($object->validate('erickskrauch@gmail.com'));
$this->assertFalse($object->validate('random@mail.ru'));
@ -34,32 +34,32 @@ class TempMailBusterTest extends \PHPUnit_Framework_TestCase
public function testGetPrimaryStorage()
{
$storage = new Storage(['test']);
$object = new TempMailBuster($storage);
$object = new Validator($storage);
$this->assertEquals($storage, $object->getPrimaryStorage());
}
public function testSetPrimaryStorage()
{
$storage = new Storage(['test2']);
$object = new TempMailBuster(new Storage(['test1']));
$object = new Validator(new Storage(['test1']));
$this->assertEquals($object, $object->setPrimaryStorage($storage));
$this->assertEquals($storage, $object->getPrimaryStorage());
}
public function testGetSecondaryStorage()
{
$object = new TempMailBuster(new Storage());
$object = new Validator(new Storage());
$this->assertNull($object->getSecondaryStorage());
$storage = new Storage(['test']);
$object = new TempMailBuster(new Storage(), $storage);
$object = new Validator(new Storage(), $storage);
$this->assertEquals($storage, $object->getSecondaryStorage());
}
public function testSetSecondaryStorage()
{
$storage = new Storage(['test2']);
$object = new TempMailBuster(new Storage());
$object = new Validator(new Storage());
$this->assertEquals($object, $object->setSecondaryStorage($storage));
$this->assertEquals($storage, $object->getSecondaryStorage());
$object->setSecondaryStorage(null);
@ -71,7 +71,7 @@ class TempMailBusterTest extends \PHPUnit_Framework_TestCase
public function testGetDomain()
{
$object = new TempMailBuster(new Storage());
$object = new Validator(new Storage());
$this->assertEquals('ely.by', $this->callGetDomain($object, 'erickskrauch@ely.by'));
$this->assertEquals('ely.by', $this->callGetDomain($object, '@ely.by'));
$this->assertEquals('ely.by', $this->callGetDomain($object, 'ely.by'));
@ -79,7 +79,7 @@ class TempMailBusterTest extends \PHPUnit_Framework_TestCase
public function testIsIsWhitelistMode()
{
$object = new TempMailBuster(new Storage());
$object = new Validator(new Storage());
$this->assertFalse($object->isIsWhitelistMode(), 'Default should be false');
$object->whitelistMode();
$this->assertTrue($object->isIsWhitelistMode());
@ -87,7 +87,7 @@ class TempMailBusterTest extends \PHPUnit_Framework_TestCase
public function testWhitelistMode()
{
$object = new TempMailBuster(new Storage());
$object = new Validator(new Storage());
$this->assertEquals($object, $object->whitelistMode());
$this->assertTrue($object->isIsWhitelistMode(), 'Default value should change mode to whitelist');
$object->whitelistMode(false);
@ -98,7 +98,7 @@ class TempMailBusterTest extends \PHPUnit_Framework_TestCase
public function testBuildRegex()
{
$object = new TempMailBuster(new Storage());
$object = new Validator(new Storage());
$this->assertEquals('/^(simple)$/', $this->callBuildRegex($object, ['simple']));
$this->assertEquals('/^(simple|another)$/', $this->callBuildRegex($object, ['simple', 'another']));
}