This repository has been archived by the owner on Nov 13, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic peer methods and state check/change methods to Subscriber…
…/Peer
- Loading branch information
Showing
4 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
ContentType: | ||
ContentType_1: | ||
name: "plain text" | ||
mime_type: "text/plain" | ||
|
||
ContentType_2: | ||
name: "HTML text" | ||
mime_type: "text/html" | ||
|
||
Newsletter: | ||
Newsletter_1: | ||
name: "first newsletter" | ||
subject: "testing one" | ||
content: "This is a plain text newsletter." | ||
content_type_id: ContentType_1 | ||
created_at: ~ | ||
scheduled_at: NULL | ||
sent_at: NULL | ||
|
||
Newsletter_2: | ||
name: "second newsletter" | ||
subject: "testing two" | ||
content: "This is <strong>not</strong> a plain text newsletter." | ||
content_type_id: ContentType_2 | ||
created_at: ~ | ||
scheduled_at: NULL | ||
sent_at: NULL | ||
|
||
Subscriber: | ||
Subscriber_1: | ||
# entered, but not activated | ||
name: "first subscriber" | ||
email: "subscriber-one@example.net" | ||
unsubscribe_hash: "92hjk248ds23" | ||
activate_hash: "892kd7823" | ||
is_active: false | ||
created_at: ~ | ||
activated_at: NULL | ||
Subscriber_2: | ||
# entered, but not activated | ||
name: "second subscriber" | ||
email: "subscriber-two@example.com" | ||
unsubscribe_hash: "asd87324" | ||
activate_hash: "5uhj32l4" | ||
is_active: false | ||
created_at: ~ | ||
activated_at: NULL | ||
Subscriber_3: | ||
# activated and unsubscribed | ||
name: "third subscriber" | ||
email: "subscriber-three@example.net" | ||
unsubscribe_hash: "723jksdo2" | ||
activate_hash: "892kd7823" | ||
is_active: false | ||
created_at: '2009-10-04 21:38:23' | ||
activated_at: '2009-10-05 22:04:32' | ||
Subscriber_4: | ||
# activated and subscribed | ||
name: "fourth subscriber" | ||
email: "subscriber-four@example.com" | ||
unsubscribe_hash: "9123hsdaa" | ||
activate_hash: "7k2j3" | ||
is_active: true | ||
created_at: '2009-10-03 21:38:23' | ||
activated_at: '2009-10-03 22:04:32' |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
require_once(dirname(__FILE__) . '/../bootstrap/unit.php'); | ||
|
||
# load fixtures of this plugin | ||
$propelData->loadData(sfConfig::get('sf_plugins_dir') . '/sfNewsletterPlugin/data/fixtures'); | ||
|
||
$limeTest = new lime_test(12, new lime_output_color()); | ||
|
||
$subscriber = SubscriberPeer::retrieveSubscribed(); | ||
$limeTest->is(count($subscriber), 1, 'Count of active subscriptions.'); | ||
|
||
$pendingActivation = SubscriberPeer::retrievePendingActivation(); | ||
$limeTest->is(count($pendingActivation), 2, 'Count of subscribers that have to activate themselves.'); | ||
|
||
$criteria = new Criteria(); | ||
$criteria->add(SubscriberPeer::EMAIL, '%example.net', Criteria::LIKE); | ||
|
||
$pendingActivation = SubscriberPeer::retrievePendingActivation($criteria); | ||
$limeTest->is(count($pendingActivation), 1, 'Count pending activation from example.net.'); | ||
|
||
$criteria = new Criteria(); | ||
$criteria->add(SubscriberPeer::EMAIL, '%example%', Criteria::LIKE); | ||
|
||
$pendingActivation = SubscriberPeer::retrievePendingActivation($criteria); | ||
$limeTest->is(count($pendingActivation), 2, 'Count pending activation from example (any TLD).'); | ||
|
||
$subscriber = SubscriberPeer::retrieveByEmail('subscriber-three@example.net'); | ||
$limeTest->isa_ok($subscriber, 'Subscriber', 'Retrieved correct class.'); | ||
$limeTest->is($subscriber->getName(), 'third subscriber', 'Retrieved by email.'); | ||
|
||
try | ||
{ | ||
SubscriberPeer::retrieveByEmail(1); | ||
$limeTest->error('Invalid email provided.'); | ||
} | ||
catch (InvalidArgumentException $e) | ||
{ | ||
$limeTest->pass('InvalidArgumentException caught on invalid email.'); | ||
} | ||
|
||
$subscriber = SubscriberPeer::retrieveByEmail('subscriber-one@example.net'); | ||
$limeTest->isa_ok($subscriber, 'Subscriber', 'Found Subscriber.'); | ||
$limeTest->is($subscriber->getName(), 'first subscriber', 'Found correct Subscriber.'); | ||
$limeTest->isnt($subscriber->isSubscribed(), true, 'Is not subscribed.'); | ||
$subscriber->activate(); | ||
$limeTest->ok($subscriber->isSubscribed(), 'Is now subscribed.'); | ||
$subscriber->unsubscribe(); | ||
$limeTest->isnt($subscriber->isSubscribed(), true, 'Is now unsubscribed.'); |