Remove refactored method from old model

[MAILPOET-4310]
This commit is contained in:
Jan Lysý
2022-08-12 14:36:52 +02:00
committed by Veljko V
parent 5f88a27ccb
commit 4687fcd44f
2 changed files with 0 additions and 53 deletions

View File

@@ -264,52 +264,6 @@ class Newsletter extends Model {
return $duplicate;
}
public function createNotificationHistory() {
$newsletterData = $this->asArray();
// remove id so that it creates a new record
unset($newsletterData['id']);
$data = array_merge(
$newsletterData,
[
'parent_id' => $this->id,
'type' => self::TYPE_NOTIFICATION_HISTORY,
'status' => self::STATUS_SENDING,
'unsubscribe_token' => Security::generateUnsubscribeToken(self::class),
]
);
$notificationHistory = self::create();
$notificationHistory->hydrate($data);
// reset timestamps
$notificationHistory->set_expr('created_at', 'NOW()');
$notificationHistory->set_expr('updated_at', 'NOW()');
$notificationHistory->set_expr('deleted_at', 'NULL');
// reset hash
$notificationHistory->set('hash', null);
$notificationHistory->save();
if ($notificationHistory->getErrors() === false) {
// create relationships between notification history and segments
$segments = $this->segments()->findMany();
if (!empty($segments)) {
foreach ($segments as $segment) {
$relation = NewsletterSegment::create();
$relation->segmentId = $segment->id;
$relation->newsletterId = $notificationHistory->id;
$relation->save();
}
}
}
return $notificationHistory;
}
public function asArray() {
$model = parent::asArray();

View File

@@ -211,13 +211,6 @@ class NewsletterTest extends \MailPoetTest {
->equals(Security::HASH_LENGTH);
}
public function testItRegeneratesHashOnNotificationHistoryCreation() {
$notificationHistory = $this->newsletter->createNotificationHistory();
expect($notificationHistory->hash)->notEquals($this->newsletter->hash);
expect(strlen($notificationHistory->hash))
->equals(Security::HASH_LENGTH);
}
public function testItGetsQueueFromNewsletter() {
expect($this->newsletter->queue()->findOne()->id)->equals($this->sendingQueue->id);
}