Exclude WordPress and WooCommerce variables from camel case conversion
[MAILPOET-1796]
This commit is contained in:
@ -67,7 +67,7 @@ class DynamicSegments {
|
||||
$products = $this->wp->getPosts($args);
|
||||
return array_map(function ($product) {
|
||||
return [
|
||||
'title' => $product->postTitle,
|
||||
'title' => $product->post_title, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'ID' => $product->ID,
|
||||
];
|
||||
}, $products);
|
||||
|
@ -80,7 +80,7 @@ class PurchasedInCategory {
|
||||
|
||||
return array_map(function($category) {
|
||||
return [
|
||||
'id' => $category->termId,
|
||||
'id' => $category->term_id, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'name' => $category->name,
|
||||
];
|
||||
}, $allCategories);
|
||||
|
@ -90,7 +90,7 @@ class PurchasedProduct {
|
||||
$woocommerceProducts = array_map(function($product) {
|
||||
return [
|
||||
'id' => $product->ID,
|
||||
'name' => $product->postTitle,
|
||||
'name' => $product->post_title, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
];
|
||||
}, $woocommerceProducts);
|
||||
return $woocommerceProducts;
|
||||
|
@ -182,7 +182,7 @@ class Populator {
|
||||
$page = null;
|
||||
if (!empty($pages)) {
|
||||
$page = array_shift($pages);
|
||||
if (strpos($page->postContent, '[mailpoet_page]') === false) {
|
||||
if (strpos($page->post_content, '[mailpoet_page]') === false) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$page = null;
|
||||
}
|
||||
}
|
||||
@ -220,8 +220,8 @@ class Populator {
|
||||
|
||||
// set default sender info based on current user
|
||||
$sender = [
|
||||
'name' => $currentUser->displayName,
|
||||
'address' => $currentUser->userEmail,
|
||||
'name' => $currentUser->display_name, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'address' => $currentUser->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
];
|
||||
|
||||
// set default from name & address
|
||||
|
@ -181,7 +181,7 @@ class Widget extends \WP_Widget {
|
||||
'widget_title',
|
||||
!empty($instance['title']) ? $instance['title'] : '',
|
||||
$instance,
|
||||
$this->idBase
|
||||
$this->id_base // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
);
|
||||
|
||||
// get form
|
||||
@ -206,7 +206,7 @@ class Widget extends \WP_Widget {
|
||||
$output = '';
|
||||
|
||||
if (!empty($body)) {
|
||||
$formId = $this->idBase . '_' . $form['id'];
|
||||
$formId = $this->id_base . '_' . $form['id']; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$data = [
|
||||
'form_id' => $formId,
|
||||
'form_type' => $formType,
|
||||
|
@ -62,17 +62,17 @@ class PHPMail {
|
||||
$mailer->clearAddresses();
|
||||
$mailer->clearCustomHeaders();
|
||||
$mailer->isHTML(!empty($newsletter['body']['html']));
|
||||
$mailer->charSet = 'UTF-8';
|
||||
$mailer->CharSet = 'UTF-8'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$mailer->setFrom($this->sender['from_email'], $this->sender['from_name'], false);
|
||||
$mailer->addReplyTo($this->replyTo['reply_to_email'], $this->replyTo['reply_to_name']);
|
||||
$subscriber = $this->processSubscriber($subscriber);
|
||||
$mailer->addAddress($subscriber['email'], $subscriber['name']);
|
||||
$mailer->subject = (!empty($newsletter['subject'])) ? $newsletter['subject'] : '';
|
||||
$mailer->body = (!empty($newsletter['body']['html'])) ? $newsletter['body']['html'] : $newsletter['body']['text'];
|
||||
if ($mailer->contentType !== 'text/plain') {
|
||||
$mailer->altBody = (!empty($newsletter['body']['text'])) ? $newsletter['body']['text'] : '';
|
||||
$mailer->Subject = (!empty($newsletter['subject'])) ? $newsletter['subject'] : ''; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$mailer->Body = (!empty($newsletter['body']['html'])) ? $newsletter['body']['html'] : $newsletter['body']['text']; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
if ($mailer->ContentType !== 'text/plain') { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$mailer->AltBody = (!empty($newsletter['body']['text'])) ? $newsletter['body']['text'] : ''; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
$mailer->sender = $this->returnPath;
|
||||
$mailer->Sender = $this->returnPath; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
if (!empty($extraParams['unsubscribe_url'])) {
|
||||
$this->mailer->addCustomHeader('List-Unsubscribe', $extraParams['unsubscribe_url']);
|
||||
}
|
||||
@ -84,8 +84,8 @@ class PHPMail {
|
||||
// sendmail command which expects only NL as line endings (POSIX). Since quoted-printable
|
||||
// requires CRLF some of those commands convert LF to CRLF which can break the email body
|
||||
// because it already (correctly) uses CRLF. Such CRLF then (wrongly) becomes CRCRLF.
|
||||
if (\PHPMailer::hasLineLongerThanMax($mailer->body)) {
|
||||
$mailer->encoding = 'base64';
|
||||
if (\PHPMailer::hasLineLongerThanMax($mailer->Body)) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$mailer->Encoding = 'base64'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
return $mailer;
|
||||
|
@ -40,7 +40,7 @@ class WordPressMailer extends \PHPMailer {
|
||||
|
||||
public function send() {
|
||||
// We need this so that the \PHPMailer class will correctly prepare all the headers.
|
||||
$this->mailer = 'mail';
|
||||
$this->Mailer = 'mail'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
|
||||
// Prepare everything (including the message) for sending.
|
||||
$this->preSend();
|
||||
@ -74,16 +74,16 @@ class WordPressMailer extends \PHPMailer {
|
||||
|
||||
private function getEmail() {
|
||||
$email = [
|
||||
'subject' => $this->subject,
|
||||
'subject' => $this->Subject, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'body' => [],
|
||||
];
|
||||
|
||||
if ($this->contentType === 'text/plain') {
|
||||
$email['body']['text'] = $this->body;
|
||||
} elseif ($this->contentType === 'text/html') {
|
||||
$text = @Html2Text::convert(strtolower($this->charSet) === 'utf-8' ? $this->body : utf8_encode($this->body));
|
||||
if ($this->ContentType === 'text/plain') { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$email['body']['text'] = $this->Body; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
} elseif ($this->ContentType === 'text/html') { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$text = @Html2Text::convert(strtolower($this->CharSet) === 'utf-8' ? $this->Body : utf8_encode($this->Body)); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$email['body']['text'] = $text;
|
||||
$email['body']['html'] = $this->body;
|
||||
$email['body']['html'] = $this->Body; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
} else {
|
||||
throw new \phpmailerException('Unsupported email content type has been used. Please use only text or HTML emails.');
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ class AutomatedLatestContent {
|
||||
// Queries with taxonomies are autodetected as 'is_archive=true' and 'is_home=false'
|
||||
// while queries without them end up being 'is_archive=false' and 'is_home=true'.
|
||||
// This is to fix that by always enforcing constistent behavior.
|
||||
$query->isArchive = true;
|
||||
$query->isHome = false;
|
||||
$query->is_archive = true; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$query->is_home = false; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
public function getPosts($args, $postsToExclude = []) {
|
||||
@ -167,7 +167,7 @@ class AutomatedLatestContent {
|
||||
foreach ($posts as $post) {
|
||||
$postsToLog[] = [
|
||||
'id' => $post->ID,
|
||||
'post_date' => $post->postDate,
|
||||
'post_date' => $post->post_date, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
];
|
||||
}
|
||||
$this->loggerFactory->getLogger(LoggerFactory::TOPIC_POST_NOTIFICATIONS)->addInfo(
|
||||
|
@ -14,7 +14,7 @@ class MetaInformationManager {
|
||||
|
||||
if (isset($args['showAuthor']) && $args['showAuthor'] === $positionField) {
|
||||
$text[] = self::getPostAuthor(
|
||||
$post->postAuthor,
|
||||
$post->post_author, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$args['authorPrecededBy']
|
||||
);
|
||||
}
|
||||
@ -22,7 +22,7 @@ class MetaInformationManager {
|
||||
if (isset($args['showCategories']) && $args['showCategories'] === $positionField) {
|
||||
$text[] = self::getPostCategories(
|
||||
$post->ID,
|
||||
$post->postType,
|
||||
$post->post_type, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$args['categoriesPrecededBy']
|
||||
);
|
||||
}
|
||||
|
@ -23,19 +23,19 @@ class PostContentManager {
|
||||
if ($displayType === 'titleOnly') {
|
||||
return '';
|
||||
}
|
||||
if ($this->woocommerceHelper->isWooCommerceActive() && $post->postType === 'product') {
|
||||
if ($this->woocommerceHelper->isWooCommerceActive() && $post->post_type === 'product') { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$product = $this->woocommerceHelper->wcGetProduct($post->ID);
|
||||
if ($product) {
|
||||
return $this->getContentForProduct($product, $displayType);
|
||||
}
|
||||
}
|
||||
if ($displayType === 'excerpt') {
|
||||
if (!empty($post->postExcerpt)) {
|
||||
return self::stripShortCodes($post->postExcerpt);
|
||||
if (!empty($post->post_excerpt)) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
return self::stripShortCodes($post->post_excerpt); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
return $this->generateExcerpt($post->postContent);
|
||||
return $this->generateExcerpt($post->post_content); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
return self::stripShortCodes($post->postContent);
|
||||
return self::stripShortCodes($post->post_content); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
public function filterContent($content, $displayType, $withPostClass = true) {
|
||||
|
@ -68,7 +68,7 @@ class PostTransformerContentsExtractor {
|
||||
|
||||
public function getFeaturedImage($post) {
|
||||
$postId = $post->ID;
|
||||
$postTitle = $this->sanitizeTitle($post->postTitle);
|
||||
$postTitle = $this->sanitizeTitle($post->post_title); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$imageFullWidth = (bool)filter_var($this->args['imageFullWidth'], FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if (!has_post_thumbnail($postId)) {
|
||||
@ -125,7 +125,7 @@ class PostTransformerContentsExtractor {
|
||||
}
|
||||
|
||||
public function getTitle($post) {
|
||||
$title = $this->sanitizeTitle($post->postTitle);
|
||||
$title = $this->sanitizeTitle($post->post_title); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
|
||||
if (filter_var($this->args['titleIsLink'], FILTER_VALIDATE_BOOLEAN)) {
|
||||
$title = '<a href="' . $this->wp->getPermalink($post->ID) . '">' . $title . '</a>';
|
||||
@ -182,7 +182,7 @@ class PostTransformerContentsExtractor {
|
||||
}
|
||||
|
||||
public function isProduct($post) {
|
||||
return $post->postType === 'product';
|
||||
return $post->post_type === 'product'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ class TitleListTransformer {
|
||||
}
|
||||
|
||||
private function getPostTitle($post) {
|
||||
$title = $post->postTitle;
|
||||
$title = $post->post_title; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$alignment = $this->args['titleAlignment'];
|
||||
$alignment = (in_array($alignment, ['left', 'right', 'center'])) ? $alignment : 'left';
|
||||
|
||||
|
@ -40,7 +40,7 @@ class PostNotificationScheduler {
|
||||
]
|
||||
);
|
||||
$types = Posts::getTypes();
|
||||
if (($newStatus !== 'publish') || !isset($types[$post->postType])) {
|
||||
if (($newStatus !== 'publish') || !isset($types[$post->post_type])) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
return;
|
||||
}
|
||||
$this->schedulePostNotification($post->ID);
|
||||
|
@ -44,8 +44,8 @@ class Newsletter {
|
||||
// Queries with taxonomies are autodetected as 'is_archive=true' and 'is_home=false'
|
||||
// while queries without them end up being 'is_archive=false' and 'is_home=true'.
|
||||
// This is to fix that by always enforcing constistent behavior.
|
||||
$query->isArchive = true;
|
||||
$query->isHome = false;
|
||||
$query->is_archive = true; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$query->is_home = false; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
private static function getLatestWPPost($postIds) {
|
||||
|
@ -31,7 +31,7 @@ class Subscriber {
|
||||
case 'displayname':
|
||||
if ($subscriber && $subscriber->wpUserId) {
|
||||
$wpUser = WPFunctions::get()->getUserdata($subscriber->wpUserId);
|
||||
return $wpUser->userLogin;
|
||||
return $wpUser->user_login; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
return $defaultValue;
|
||||
case 'count':
|
||||
|
@ -51,23 +51,23 @@ class Track {
|
||||
|
||||
public function _processTrackData($data) {
|
||||
$data = (object)Links::transformUrlDataObject($data);
|
||||
if (empty($data->queueId) ||
|
||||
empty($data->subscriberId) ||
|
||||
empty($data->subscriberToken)
|
||||
if (empty($data->queue_id) || // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
empty($data->subscriber_id) || // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
empty($data->subscriber_token) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
$data->queue = SendingQueue::findOne($data->queueId);
|
||||
$data->queue = SendingQueue::findOne($data->queue_id); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
if ($data->queue instanceof SendingQueue) {
|
||||
$data->queue = SendingTask::createFromQueue($data->queue);
|
||||
}
|
||||
$data->subscriber = Subscriber::findOne($data->subscriberId) ?: null;
|
||||
$data->newsletter = (!empty($data->queue->newsletterId)) ?
|
||||
Newsletter::findOne($data->queue->newsletterId) :
|
||||
$data->subscriber = Subscriber::findOne($data->subscriber_id) ?: null; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$data->newsletter = (!empty($data->queue->newsletter_id)) ? // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
Newsletter::findOne($data->queue->newsletter_id) : // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
false;
|
||||
if (!empty($data->linkHash)) {
|
||||
$data->link = NewsletterLink::where('hash', $data->linkHash)
|
||||
->where('queue_id', $data->queueId)
|
||||
if (!empty($data->link_hash)) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$data->link = NewsletterLink::where('hash', $data->link_hash) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
->where('queue_id', $data->queue_id) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
->findOne();
|
||||
}
|
||||
return $this->_validateTrackData($data);
|
||||
@ -75,7 +75,7 @@ class Track {
|
||||
|
||||
public function _validateTrackData($data) {
|
||||
if (!$data->subscriber || !$data->queue || !$data->newsletter) return false;
|
||||
$subscriberTokenMatch = $this->linkTokens->verifyToken($data->subscriber, $data->subscriberToken);
|
||||
$subscriberTokenMatch = $this->linkTokens->verifyToken($data->subscriber, $data->subscriber_token); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
if (!$subscriberTokenMatch) {
|
||||
$this->terminate(403);
|
||||
}
|
||||
|
@ -40,16 +40,16 @@ class WP {
|
||||
case 'added_existing_user':
|
||||
default:
|
||||
// get first name & last name
|
||||
$firstName = $wpUser->firstName;
|
||||
$lastName = $wpUser->lastName;
|
||||
if (empty($wpUser->firstName) && empty($wpUser->lastName)) {
|
||||
$firstName = $wpUser->displayName;
|
||||
$firstName = $wpUser->first_name; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$lastName = $wpUser->last_name; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
if (empty($wpUser->first_name) && empty($wpUser->last_name)) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$firstName = $wpUser->display_name; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
$signupConfirmationEnabled = SettingsController::getInstance()->get('signup_confirmation.enabled');
|
||||
// subscriber data
|
||||
$data = [
|
||||
'wp_user_id' => $wpUser->ID,
|
||||
'email' => $wpUser->userEmail,
|
||||
'email' => $wpUser->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'first_name' => $firstName,
|
||||
'last_name' => $lastName,
|
||||
'status' => $signupConfirmationEnabled ? Subscriber::STATUS_UNCONFIRMED : Subscriber::STATUS_SUBSCRIBED,
|
||||
|
@ -122,11 +122,11 @@ class WooCommerce {
|
||||
$mailpoetEmailColumn = $wpdb->get_row(
|
||||
'SHOW FULL COLUMNS FROM ' . MP_SUBSCRIBERS_TABLE . ' WHERE Field = "email"'
|
||||
);
|
||||
$this->mailpoetEmailCollation = $mailpoetEmailColumn->collation;
|
||||
$this->mailpoetEmailCollation = $mailpoetEmailColumn->Collation; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpPostmetaValueColumn = $wpdb->get_row(
|
||||
'SHOW FULL COLUMNS FROM ' . $wpdb->postmeta . ' WHERE Field = "meta_value"'
|
||||
);
|
||||
$this->wpPostmetaValueCollation = $wpPostmetaValueColumn->collation;
|
||||
$this->wpPostmetaValueCollation = $wpPostmetaValueColumn->Collation; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
private function needsCollationChange($collation1, $collation2) {
|
||||
|
@ -23,7 +23,7 @@ class AutomatedLatestContentTest extends \MailPoetTest {
|
||||
// WP's default post type 'revision' is excluded from search
|
||||
// https://codex.wordpress.org/Post_Types
|
||||
$revisionPostType = get_post_type_object('revision');
|
||||
expect($revisionPostType->excludeFromSearch)->true();
|
||||
expect($revisionPostType->exclude_from_search)->true(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect(isset($response->data['revision']))->false();
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class MP2MigratorTest extends \MailPoetTest {
|
||||
|
||||
// Check if the subscribers number is equal to the WordPress users number
|
||||
// On multisite environment, there's only 1 users table that's shared by subsites
|
||||
$WPUsersCount = ORM::for_table($wpdb->basePrefix . 'users')->count();
|
||||
$WPUsersCount = ORM::for_table($wpdb->base_prefix . 'users')->count(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect(Subscriber::count())->equals($WPUsersCount);
|
||||
|
||||
// Check if the custom fields number is 0
|
||||
@ -310,10 +310,10 @@ class MP2MigratorTest extends \MailPoetTest {
|
||||
$table = MP_SUBSCRIBERS_TABLE;
|
||||
$subscriber = $wpdb->get_row("SELECT * FROM $table WHERE email='$email'");
|
||||
expect($subscriber->email)->equals($email);
|
||||
expect($subscriber->firstName)->equals($firstname);
|
||||
expect($subscriber->lastName)->equals($lastname);
|
||||
expect($subscriber->subscribedIp)->equals($ip);
|
||||
expect($subscriber->confirmedIp)->equals($confirmedIp);
|
||||
expect($subscriber->first_name)->equals($firstname); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($subscriber->last_name)->equals($lastname); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($subscriber->subscribed_ip)->equals($ip); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($subscriber->confirmed_ip)->equals($confirmedIp); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($subscriber->status)->equals('subscribed');
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class ShortcodesTest extends \MailPoetTest {
|
||||
expect(trim(Shortcodes::process($content)))->equals('Subject line with one shortcode:');
|
||||
|
||||
// when tag is found, the shortcode will be processed and replaced
|
||||
expect(Shortcodes::process($content, $contentSource))->equals('Subject line with one shortcode: ' . $wpPost->postTitle);
|
||||
expect(Shortcodes::process($content, $contentSource))->equals('Subject line with one shortcode: ' . $wpPost->post_title); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
|
@ -51,7 +51,9 @@ class PHPMailTest extends \MailPoetTest {
|
||||
public function testItCanBuildMailer() {
|
||||
$mailer = $this->mailer->buildMailer();
|
||||
expect($mailer)->isInstanceOf('PHPMailer');
|
||||
expect($mailer->mailer)->equals('mail'); // uses PHP's mail() function
|
||||
|
||||
// uses PHP's mail() function
|
||||
expect($mailer->Mailer)->equals('mail'); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
public function testWhenReturnPathIsNullItIsSetToSenderEmail() {
|
||||
@ -67,7 +69,7 @@ class PHPMailTest extends \MailPoetTest {
|
||||
public function testItCanConfigureMailerWithMessage() {
|
||||
$mailer = $this->mailer
|
||||
->configureMailerWithMessage($this->newsletter, $this->subscriber, $this->extraParams);
|
||||
expect($mailer->charSet)->equals('UTF-8');
|
||||
expect($mailer->CharSet)->equals('UTF-8'); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($mailer->getToAddresses())->equals(
|
||||
[
|
||||
[
|
||||
@ -78,8 +80,8 @@ class PHPMailTest extends \MailPoetTest {
|
||||
);
|
||||
expect($mailer->getAllRecipientAddresses())
|
||||
->equals(['mailpoet-phoenix-test@mailinator.com' => true]);
|
||||
expect($mailer->from)->equals($this->sender['from_email']);
|
||||
expect($mailer->fromName)->equals($this->sender['from_name']);
|
||||
expect($mailer->From)->equals($this->sender['from_email']); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($mailer->FromName)->equals($this->sender['from_name']); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($mailer->getReplyToAddresses())->equals(
|
||||
[
|
||||
'reply-to@mailpoet.com' => [
|
||||
@ -88,12 +90,12 @@ class PHPMailTest extends \MailPoetTest {
|
||||
],
|
||||
]
|
||||
);
|
||||
expect($mailer->sender)->equals($this->returnPath);
|
||||
expect($mailer->contentType)->equals('text/html');
|
||||
expect($mailer->subject)->equals($this->newsletter['subject']);
|
||||
expect($mailer->body)
|
||||
expect($mailer->Sender)->equals($this->returnPath); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($mailer->ContentType)->equals('text/html'); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($mailer->Subject)->equals($this->newsletter['subject']); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($mailer->Body) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
->equals($this->newsletter['body']['html']);
|
||||
expect($mailer->altBody)
|
||||
expect($mailer->AltBody) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
->equals($this->newsletter['body']['text']);
|
||||
expect($mailer->getCustomHeaders())->equals(
|
||||
[
|
||||
@ -113,8 +115,8 @@ class PHPMailTest extends \MailPoetTest {
|
||||
'text' => 'TEXT body',
|
||||
],
|
||||
], $this->subscriber);
|
||||
expect($mailer->contentType)->equals('text/plain');
|
||||
expect($mailer->body)->equals('TEXT body');
|
||||
expect($mailer->ContentType)->equals('text/plain'); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($mailer->Body)->equals('TEXT body'); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
public function testItCanProcessSubscriber() {
|
||||
|
@ -45,8 +45,8 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com');
|
||||
$wpMailer->subject = 'Subject';
|
||||
$wpMailer->body = 'Email Text Body';
|
||||
$wpMailer->Subject = 'Subject'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->Body = 'Email Text Body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->isHTML(false);
|
||||
$wpMailer->send();
|
||||
}
|
||||
@ -66,8 +66,8 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com', 'Full Name');
|
||||
$wpMailer->subject = 'Subject';
|
||||
$wpMailer->body = 'Body';
|
||||
$wpMailer->Subject = 'Subject'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->Body = 'Body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->isHTML(false);
|
||||
$wpMailer->send();
|
||||
}
|
||||
@ -90,8 +90,8 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com');
|
||||
$wpMailer->subject = 'Subject';
|
||||
$wpMailer->body = 'Email Html Body';
|
||||
$wpMailer->Subject = 'Subject'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->Body = 'Email Html Body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->isHTML(true);
|
||||
$wpMailer->send();
|
||||
}
|
||||
@ -107,7 +107,7 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com');
|
||||
$wpMailer->body = 'body';
|
||||
$wpMailer->Body = 'body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($wpMailer->send())->true();
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com');
|
||||
$wpMailer->body = 'body';
|
||||
$wpMailer->Body = 'body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($wpMailer->send())->true();
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com');
|
||||
$wpMailer->body = 'body';
|
||||
$wpMailer->Body = 'body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
|
||||
$errorMessage = null;
|
||||
try {
|
||||
@ -167,8 +167,8 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com');
|
||||
$wpMailer->body = 'body';
|
||||
$wpMailer->contentType = 'application/json';
|
||||
$wpMailer->Body = 'body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->ContentType = 'application/json'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$this->expectException(\phpmailerException::class);
|
||||
$wpMailer->send();
|
||||
}
|
||||
@ -187,7 +187,7 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com');
|
||||
$wpMailer->body = 'body';
|
||||
$wpMailer->Body = 'body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
|
||||
$errorMessage = null;
|
||||
try {
|
||||
@ -225,8 +225,8 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
|
||||
$wpMailer = new WordPressMailer($mailer, $fallbackMailer, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com', 'Full Name');
|
||||
$wpMailer->subject = 'Subject';
|
||||
$wpMailer->body = 'Body';
|
||||
$wpMailer->Subject = 'Subject'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->Body = 'Body'; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$wpMailer->send();
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ class ShortcodesTest extends \MailPoetTest {
|
||||
$result =
|
||||
$shortcodesObject->process(['[newsletter:post_title]'], $content);
|
||||
$wpPost = get_post($this->wPPost);
|
||||
expect($result['0'])->equals($wpPost->postTitle);
|
||||
expect($result['0'])->equals($wpPost->post_title); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
}
|
||||
|
||||
public function itCanProcessPostNotificationNewsletterNumberShortcode() {
|
||||
|
@ -41,7 +41,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$subscriber->hydrate([
|
||||
'first_name' => 'Mike',
|
||||
'last_name' => 'Mike',
|
||||
'email' => $user->userEmail,
|
||||
'email' => $user->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'wp_user_id' => $user->ID,
|
||||
]);
|
||||
$subscriber->status = Subscriber::STATUS_SUBSCRIBED;
|
||||
@ -54,7 +54,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
->where('wp_user_id', $user->ID)
|
||||
->findOne();
|
||||
expect($subscriber)->notEmpty();
|
||||
expect($subscriber->email)->equals($user->userEmail);
|
||||
expect($subscriber->email)->equals($user->user_email); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($subscriber->isWoocommerceUser)->equals(1);
|
||||
expect($subscriber->source)->equals(Source::WOOCOMMERCE_USER);
|
||||
expect($subscriber->deletedAt)->equals(null);
|
||||
@ -66,7 +66,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$subscriber->hydrate([
|
||||
'first_name' => 'Mike',
|
||||
'last_name' => 'Mike',
|
||||
'email' => $user->userEmail,
|
||||
'email' => $user->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'wp_user_id' => $user->ID,
|
||||
]);
|
||||
$subscriber->status = Subscriber::STATUS_UNSUBSCRIBED;
|
||||
@ -78,7 +78,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
->where('wp_user_id', $user->ID)
|
||||
->findOne();
|
||||
expect($subscriber)->notEmpty();
|
||||
expect($subscriber->email)->equals($user->userEmail);
|
||||
expect($subscriber->email)->equals($user->user_email); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($subscriber->isWoocommerceUser)->equals(1);
|
||||
expect($subscriber->source)->equals(Source::WORDPRESS_USER); // no overriding
|
||||
expect($subscriber->status)->equals(Subscriber::STATUS_UNSUBSCRIBED); // no overriding
|
||||
@ -91,7 +91,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$subscriber->hydrate([
|
||||
'first_name' => 'Mike',
|
||||
'last_name' => 'Mike',
|
||||
'email' => $user->userEmail,
|
||||
'email' => $user->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'wp_user_id' => $user->ID,
|
||||
]);
|
||||
$subscriber->status = Subscriber::STATUS_UNSUBSCRIBED;
|
||||
@ -126,7 +126,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$this->woocommerceSegment->synchronizeCustomers();
|
||||
$subscribersCount = $this->getSubscribersCount();
|
||||
expect($subscribersCount)->equals(2);
|
||||
$subscriber = Subscriber::where('email', $user->userEmail)->findOne();
|
||||
$subscriber = Subscriber::where('email', $user->user_email)->findOne(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
expect($subscriber->status)->equals(Subscriber::STATUS_UNCONFIRMED);
|
||||
expect($subscriber->source)->equals(Source::WOOCOMMERCE_USER);
|
||||
$subscriber = Subscriber::where('email', $guest['email'])->findOne();
|
||||
@ -202,7 +202,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$user = $this->insertRegisteredCustomerWithOrder(null, ['first_name' => '']);
|
||||
$this->woocommerceSegment->synchronizeCustomers();
|
||||
update_post_meta($user->orderId, '_billing_first_name', 'First name');
|
||||
$this->createOrder(['email' => $user->userEmail, 'first_name' => 'First name (newer)']);
|
||||
$this->createOrder(['email' => $user->user_email, 'first_name' => 'First name (newer)']); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$this->woocommerceSegment->synchronizeCustomers();
|
||||
$subscriber = Subscriber::where('wp_user_id', $user->ID)->findOne();
|
||||
expect($subscriber->firstName)->equals('First name (newer)');
|
||||
@ -212,7 +212,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$user = $this->insertRegisteredCustomerWithOrder(null, ['last_name' => '']);
|
||||
$this->woocommerceSegment->synchronizeCustomers();
|
||||
update_post_meta($user->orderId, '_billing_last_name', 'Last name');
|
||||
$this->createOrder(['email' => $user->userEmail, 'last_name' => 'Last name (newer)']);
|
||||
$this->createOrder(['email' => $user->user_email, 'last_name' => 'Last name (newer)']); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$this->woocommerceSegment->synchronizeCustomers();
|
||||
$subscriber = Subscriber::where('wp_user_id', $user->ID)->findOne();
|
||||
expect($subscriber->lastName)->equals('Last name (newer)');
|
||||
@ -253,13 +253,13 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
public function testItRemovesRegisteredCustomersFromTrash() {
|
||||
$user = $this->insertRegisteredCustomer();
|
||||
$this->woocommerceSegment->synchronizeCustomers();
|
||||
$subscriber = Subscriber::where("email", $user->userEmail)
|
||||
$subscriber = Subscriber::where("email", $user->user_email) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
->where('is_woocommerce_user', 1)
|
||||
->findOne();
|
||||
$subscriber->deletedAt = Carbon::now();
|
||||
$subscriber->save();
|
||||
$this->woocommerceSegment->synchronizeCustomers();
|
||||
$subscriber = Subscriber::where("email", $user->userEmail)
|
||||
$subscriber = Subscriber::where("email", $user->user_email) // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
->where('is_woocommerce_user', 1)
|
||||
->findOne();
|
||||
expect($subscriber->deletedAt)->null();
|
||||
@ -306,7 +306,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$subscriber->hydrate([
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'John',
|
||||
'email' => $user->userEmail,
|
||||
'email' => $user->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'wp_user_id' => $user->ID,
|
||||
]);
|
||||
$subscriber->status = Subscriber::STATUS_UNCONFIRMED;
|
||||
@ -432,7 +432,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$user2 = $this->insertRegisteredCustomer();
|
||||
|
||||
$subscriber1 = Subscriber::createOrUpdate([
|
||||
'email' => $user1->userEmail,
|
||||
'email' => $user1->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'is_woocommerce_user' => 1,
|
||||
'status' => Subscriber::STATUS_UNSUBSCRIBED,
|
||||
]);
|
||||
@ -443,7 +443,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$association1->save();
|
||||
|
||||
$subscriber2 = Subscriber::createOrUpdate([
|
||||
'email' => $user2->userEmail,
|
||||
'email' => $user2->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'is_woocommerce_user' => 1,
|
||||
'status' => Subscriber::STATUS_UNSUBSCRIBED,
|
||||
'confirmed_ip' => '123',
|
||||
@ -474,7 +474,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$user2 = $this->insertRegisteredCustomer();
|
||||
|
||||
$subscriber1 = Subscriber::createOrUpdate([
|
||||
'email' => $user1->userEmail,
|
||||
'email' => $user1->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'is_woocommerce_user' => 1,
|
||||
'status' => Subscriber::STATUS_SUBSCRIBED,
|
||||
]);
|
||||
@ -485,7 +485,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$association1->save();
|
||||
|
||||
$subscriber2 = Subscriber::createOrUpdate([
|
||||
'email' => $user2->userEmail,
|
||||
'email' => $user2->user_email, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
'is_woocommerce_user' => 1,
|
||||
'status' => Subscriber::STATUS_SUBSCRIBED,
|
||||
'confirmed_ip' => '123',
|
||||
@ -607,7 +607,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
// add customer role
|
||||
$user = new WPUserWithExtraProps($id);
|
||||
$user->add_role('customer');
|
||||
$this->userEmails[] = $user->userEmail;
|
||||
$this->userEmails[] = $user->user_email; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
return $user;
|
||||
}
|
||||
|
||||
@ -631,7 +631,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
$number = !is_null($number) ? (int)$number : mt_rand();
|
||||
$user = $this->insertRegisteredCustomer($number);
|
||||
$data = is_array($data) ? $data : [];
|
||||
$data['email'] = $user->userEmail;
|
||||
$data['email'] = $user->user_email; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
||||
$data['user_id'] = $user->ID;
|
||||
$user->orderId = $this->createOrder($data);
|
||||
return $user;
|
||||
|
Reference in New Issue
Block a user