Skip to content

Commit

Permalink
sfSendRegistMailのテストを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
clicktx committed Aug 30, 2024
1 parent d9568e7 commit 62d44b0
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

$HOME = realpath(dirname(__FILE__)) . "/../../../../";
require_once($HOME . "/tests/class/Common_TestCase.php");
/**
*
*/
class SC_Helper_Mail_TestBase extends Common_TestCase
{
/** @var int */
protected $customer_id;

/** @var Faker\Generator $faker */
protected $faker;

/** @var string */
protected $email;

/** @var array */
protected $arrCustomer;

/** @var SC_Customer_Ex */
protected $objCustomer;

/** @var SC_Helper_Mail_Ex */
protected $objHelperMail;


protected function setUp()
{
parent::setUp();
$this->checkMailCatcherStatus();
$this->objHelperMail = new SC_Helper_Mail_Ex();

$this->faker = Faker\Factory::create('ja_JP');
}

protected function tearDown()
{
parent::tearDown();
}

protected function setUpCustomer($properties = [])
{
$this->email = $this->faker->safeEmail;
$this->customer_id = $this->objGenerator->createCustomer($this->email, $properties);
$this->arrCustomer = $this->objQuery->getRow('*', 'dtb_customer', 'customer_id = ?', [$this->customer_id]);
$this->objCustomer = new SC_Customer_Ex();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

$HOME = realpath(dirname(__FILE__)) . "/../../../..";
require_once($HOME . "/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php");
/**
*
*/
class SC_Helper_Mail_sfSendRegistMailTest extends SC_Helper_Mail_TestBase
{
protected function setUp()
{
parent::setUp();
}

protected function tearDown()
{
parent::tearDown();
}

/////////////////////////////////////////

public function test会員登録メールの宛名が正しい()
{
# 本会員を作成
$this->setUpCustomer();

$this->resetEmails();
$this->objHelperMail->sfSendRegistMail($this->arrCustomer['secret_key']);

$message = $this->getLastMailCatcherMessage();
$this->assertContains($this->arrCustomer['name01'] . $this->arrCustomer['name02'] . '', $message['source']);
}

public function test会員登録依頼メールの宛名が正しい()
{
# 仮会員を作成
$this->setUpCustomer(['status' => 1]);

$this->resetEmails();
$this->objHelperMail->sfSendRegistMail($this->arrCustomer['secret_key'], '', false, true);

$message = $this->getLastMailCatcherMessage();
$this->assertContains($this->arrCustomer['name01'] . ' ' . $this->arrCustomer['name02'] . '', $message['source']);
$this->assertContains('&id=' . $this->arrCustomer['secret_key'], $message['source']);
}
}

0 comments on commit 62d44b0

Please sign in to comment.