Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unitTest_MailConfigsController_index #3425

Merged
merged 7 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MailConfigsController extends MailAdminAppController
* @return void|ResponseInterface
* @checked
* @noTodo
* @unitTest
*/
public function index(MailConfigsServiceInterface $service)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@
* @license https://basercms.net/license/index.html
*/
namespace BcMail\Test\TestCase\Controller\Admin;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

class MailConfigsControllerTest extends BcTestCase
{
/**
* ScenarioAwareTrait
*/
use ScenarioAwareTrait;

/**
* set up
*
* @return void
*/
public function setUp(): void
{
// $this->MailConfigs = new MailConfigsController(new CakeRequest(null, false), new CakeResponse());
//
// $this->Case = $this->getMockForAbstractClass('ControllerTestCase');

parent::setUp();
$this->loadFixtureScenario(InitAppScenario::class);
}

/**
Expand All @@ -34,8 +38,6 @@ public function setUp(): void
*/
public function tearDown(): void
{
// unset($this->MailConfigs);
// unset($this->Case);
parent::tearDown();
}

Expand Down Expand Up @@ -74,4 +76,24 @@ public static function admin_formDataProvider()
], '\/admin\/mail\/mail_configs\/form']
];
}

/**
* test index
*/
public function testIndex()
{
$this->loginAdmin($this->getRequest('/'));
$this->enableSecurityToken();
$this->enableCsrfToken();

//request is get
$this->get('/baser/admin/bc-mail/mail_configs/index');
$this->assertResponseOk();

//request is post
$this->post('/baser/admin/bc-mail/mail_configs/index', ['name_add' => 'test']);
$this->assertResponseCode(302);
$this->assertFlashMessage('メールプラグイン設定を保存しました。');
$this->assertRedirect('/baser/admin/bc-mail/mail_configs/index');
}
}
Loading