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 2 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,28 @@
* @license https://basercms.net/license/index.html
*/
namespace BcMail\Test\TestCase\Controller\Admin;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BcMail\Controller\Admin\MailConfigsController;
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);
$this->MailConfigsController = new MailConfigsController($this->loginAdmin($this->getRequest()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thangnnmd @HungDV2022 この行は使ってないですね

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thangnnmd
làm giống thằng này xem nhé a
#3423 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryuring
こちらを調整しました。確認お願いします。

}

/**
Expand All @@ -34,8 +40,7 @@ public function setUp(): void
*/
public function tearDown(): void
{
// unset($this->MailConfigs);
// unset($this->Case);
unset($this->MailConfigsController);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thangnnmd @HungDV2022 これは不要ですね

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryuring こちらを修正しました。確認お願いします。

parent::tearDown();
}

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

/**
* test index
*/
public function testIndex()
{
$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