Skip to content

Commit

Permalink
Save login in session
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Apr 24, 2023
1 parent 4fd25bb commit 981c9f7
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 17 deletions.
14 changes: 7 additions & 7 deletions tests/Acceptance/Administrator/ArticleEditCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function canSeeAttachmentDetails(Attachment $I, Article $IA)
$article = $IA->createArticle(['title' => 'Test title']);
$I->createAttachment(['path' => 'test.txt', 'item_id' => $article['id']]);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_content&task=article.edit&id=' . $article['id']);
$I->click('Attachments');

Expand All @@ -43,7 +43,7 @@ public function canSeeUploadFormInArticleForm(Article $I)

$article = $I->createArticle(['title' => 'Test title']);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_content&task=article.edit&id=' . $article['id']);
$I->click('Attachments');

Expand All @@ -58,7 +58,7 @@ public function cantSeeUploadFormInArticleFormWhenDisabledExtension(Article $I)

$article = $I->createArticle(['title' => 'Test title']);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_content&task=article.edit&id=' . $article['id']);

$I->dontSee('Attachments');
Expand Down Expand Up @@ -104,7 +104,7 @@ public function canUploadAttachmentOnArticleFormPage(Article $I)

$article = $I->createArticle(['title' => 'Test title']);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_content&task=article.edit&id=' . $article['id']);
$I->click('Attachments');

Expand All @@ -122,7 +122,7 @@ public function canUploadMultipleAttachmentOnArticleFormPage(Article $I)

$article = $I->createArticle(['title' => 'Test title']);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_content&task=article.edit&id=' . $article['id']);
$I->click('Attachments');

Expand All @@ -144,7 +144,7 @@ public function canTrashAttachment(Attachment $I, Article $IA)
$article = $IA->createArticle(['title' => 'Test title']);
$I->createAttachment(['path' => 'test.txt', 'item_id' => $article['id']]);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_content&task=article.edit&id=' . $article['id']);
$I->click('Attachments');
$I->click('Trash');
Expand All @@ -158,7 +158,7 @@ public function canSeeInformationMessageWhenArticleIsNotSaved(Article $I)
{
$I->wantToTest('that an information message is shown when an article is not saved.');

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_content&task=article.edit');
$I->click('Attachments');

Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Administrator/AttachmentEditCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function canEditAttachment(Attachment $I)

$I->createAttachment(['path' => 'test.jpg']);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage(AttachmentsListPage::$url);
$I->click('test.jpg');
$I->waitForElement(AttachmentFormPage::$rootClass);
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Administrator/AttachmentsListCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function _before(AcceptanceTester $I)
{
parent::_before($I);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
}

public function canNavigateToAttachmentForm(Attachment $I)
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Administrator/ConfigEditCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function cantSeeAttachmentDetails(Attachment $I)
{
$I->wantToTest('that the attachment details are not shown in the global config form.');

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_config&view=component&component=com_content');

$I->dontSee('Attachments', '#config');
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Administrator/MediaListCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function _before(AcceptanceTester $I)
{
parent::_before($I);

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();

if (is_dir($I->getConfiguration('home_dir') . '/images/test')) {
(new FileSystem())->deleteDir($I->getConfiguration('home_dir') . '/images/test');
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Administrator/MenuEditCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function cantSeeAttachmentDetails(Attachment $I)
{
$I->wantToTest('that the attachment details are not shown in the menu item form.');

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_menus&task=menu.edit');

$I->dontSee('Attachments');
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Administrator/PluginEditCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function cantSeeAttachmentDetails(Attachment $I)
{
$I->wantToTest('that the attachment details are not shown in the plugin form.');

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage(
'/administrator/index.php?option=com_plugins&task=plugin.edit&extension_id=' . $I->grabFromDatabase('extensions', 'extension_id', [])
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/Administrator/TaskEditCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function cantSeeAttachmentDetails(Attachment $I)
{
$I->wantToTest('that the attachment details are not shown in the task form.');

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('/administrator/index.php?option=com_scheduler&view=select&layout=default');
$I->click('Demo Task');

Expand Down
30 changes: 28 additions & 2 deletions tests/Support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,34 @@

namespace Tests\Support\Helper;

class Acceptance extends \Codeception\Module
use Codeception\Module;

class Acceptance extends Module
{
public function doFrontEndLogin($user = null, $password = null, $useSnapshot = true)
{
/** @var JoomlaBrowser $browser */
$I = $this->getModule('Joomla\Browser\JoomlaBrowser');

if (is_null($user)) {
$user = $I->_getConfig('username');
}

if (is_null($password)) {
$password = $I->_getConfig('password');
}

if ($useSnapshot && $I->loadSessionSnapshot('front' . $user)) {
return;
}

$I->doFrontEndLogin($user, $password);

if ($useSnapshot) {
$I->saveSessionSnapshot('front' . $user);
}
}

public function getConfiguration($element = null)
{
if (is_null($element)) {
Expand Down Expand Up @@ -63,7 +89,7 @@ public function createCat($title)
/** @var Joomla\Browser\JoomlaBrowser $browser */
$I = $this->getModule('Joomla\Browser\JoomlaBrowser');

$I->doAdministratorLogin(null, null, false);
$I->doAdministratorLogin();
$I->amOnPage('administrator/index.php?option=com_categories&extension=com_content');
$I->click('New');
$I->fillField(['id' => 'jform_title'], $title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

class AttachmentsListPage extends AcceptanceTester
{
public static $url = '/administrator/index.php?option=com_dpattachments&view=attachments';
public static $url = '/administrator/index.php?option=com_dpattachments&view=attachments&filter[state]=';
public static $rootClass = '.com-dpattachments-attachments';
}

0 comments on commit 981c9f7

Please sign in to comment.