public function testWhetherNewsletterExists() { global $wpdb; $whetherNewsletterExists = Newsletter::whetherNewsletterIDExists(9801); $this->assertFalse($whetherNewsletterExists); $newsletter = array("name" => md5(microtime()), "reply_to" => 'flarecore@' . md5(microtime()) . '.com', "fromname" => 'Test', "fromemail" => 'flare@' . md5(microtime()) . '.com'); $addNewsletterQuery = sprintf("INSERT INTO %swpr_newsletters (`name`, `reply_to`, `fromname`, `fromemail`) VALUES ('%s','%s', '%s', '%s')", $wpdb->prefix, $newsletter['name'], $newsletter['reply_to'], $newsletter['fromname'], $newsletter['fromemail']); $wpdb->query($addNewsletterQuery); $newsletter_id = $wpdb->insert_id; $this->assertTrue(Newsletter::whetherNewsletterIDExists($newsletter_id)); }
public static function validateAddFormPostData($post_data, &$errors) { $name = $post_data['name']; if (!Autoresponder::whetherValidAutoresponderName(array('name' => $name))) { $errors[] = __("The name for the autoresponder you've entered is invalid"); } if (!Newsletter::whetherNewsletterIDExists($post_data['nid'])) { $errors[] = __("The newsletter you've selected doesn't exist"); return $errors; } }
public static function addAutoresponder($nid, $name) { global $wpdb; if (!Newsletter::whetherNewsletterIDExists($nid)) { throw new NonExistentNewsletterAutoresponderAdditionException(); } if (!Autoresponder::whetherValidAutoresponderName(array("nid" => $nid, "name" => $name))) { throw new InvalidArgumentException("Invalid autoresponder arguments"); } $createAutoresponderQuery = sprintf("INSERT INTO `{$wpdb->prefix}wpr_autoresponders` (`nid`, `name`) VALUES (%d, '%s');", $nid, $name); $wpdb->query($createAutoresponderQuery); $autoresponder_id = $wpdb->insert_id; return new Autoresponder($autoresponder_id); }
public static function getSubscribersOfNewsletter($nid) { if (false == Newsletter::whetherNewsletterIDExists($nid)) { throw new NewsletterNotFoundException(); } throw new BadMethodCallException("Subscribers of newsletter get yet to be implemented "); }