- Updates unit tests

This commit is contained in:
Vlad
2016-12-18 22:46:42 -05:00
parent 9698cf2d2e
commit 9095482af2
7 changed files with 322 additions and 46 deletions

View File

@@ -9,7 +9,6 @@ use MailPoet\Models\SubscriberCustomField;
use MailPoet\Models\SubscriberSegment;
class SubscriberTest extends MailPoetTest {
function _before() {
$this->data = array(
'first_name' => 'John',
@@ -555,6 +554,23 @@ class SubscriberTest extends MailPoetTest {
expect($total)->equals(1);
}
function testItGeneratesSubscriberToken() {
$token = Subscriber::generateToken($this->data['email']);
expect(strlen($token))->equals(Subscriber::SUBSCRIBER_TOKEN_LENGTH);
}
function testItVerifiesSubscriberToken() {
$token = Subscriber::generateToken($this->data['email']);
expect(Subscriber::verifyToken($this->data['email'], $token))->true();
expect(Subscriber::verifyToken('fake@email.com', $token))->false();
}
function testVerifiedTokensOfDifferentLengths() {
$token = md5(AUTH_KEY . $this->data['email']);
expect(strlen($token))->notEquals(Subscriber::SUBSCRIBER_TOKEN_LENGTH);
expect(Subscriber::verifyToken($this->data['email'], $token))->true();
}
function _after() {
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
ORM::raw_execute('TRUNCATE ' . Segment::$_table);
@@ -562,4 +578,4 @@ class SubscriberTest extends MailPoetTest {
ORM::raw_execute('TRUNCATE ' . CustomField::$_table);
ORM::raw_execute('TRUNCATE ' . SubscriberCustomField::$_table);
}
}
}