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

LC_Page_Admin_*_Ex のクラスパスが正常に取得できないのを修正 #553

Merged
merged 3 commits into from
Aug 3, 2022
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
9 changes: 8 additions & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
strategy:
fail-fast: false
matrix:
pattern:
- 'test:e2e'
- 'test:e2e-extends'
group:
- 'test/front_login'
- 'test/front_guest'
Expand All @@ -35,6 +38,9 @@ jobs:
- name: Setup environment
run: echo "COMPOSE_FILE=docker-compose.yml:docker-compose.pgsql.yml:docker-compose.dev.yml:docker-compose.owaspzap.yml:docker-compose.owaspzap.daemon.yml" >> $GITHUB_ENV

- if: matrix.pattern == 'test:e2e-extends'
run: cp -rp tests/class/fixtures/page_extends/* data/class_extends/page_extends

- name: Setup to EC-CUBE
env:
HTTP_URL: https://127.0.0.1:8085/
Expand All @@ -57,11 +63,12 @@ jobs:
- name: Run to E2E testing
env:
GROUP: ${{ matrix.group }}
PATTERN: ${{ matrix.pattern }}
HTTPS_PROXY: 'localhost:8090'
HTTP_PROXY: 'localhost:8090'
CI: 1
FORCE_COLOR: 1
run: yarn test:e2e e2e-tests/${GROUP}
run: yarn ${PATTERN} e2e-tests/${GROUP}

- name: Upload evidence
if: failure()
Expand Down
6 changes: 5 additions & 1 deletion data/class/SC_ClassAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R
$arrClassNamePartTemp = $arrClassNamePart;
// FIXME クラスファイルのディレクトリ命名が変。変な現状に合わせて強引な処理をしてる。
$arrClassNamePartTemp[1] = $arrClassNamePartTemp[1] . '_extends';
$classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -2))) . '/';
if ($count <= 5 && $arrClassNamePart[2] === 'Admin' && !in_array($arrClassNamePart[3], ['Home', 'Index', 'Logout'])) {
$classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -1))) . '/';
} else {
$classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -2))) . '/';
}
} elseif ($arrClassNamePart[0] === 'SC' && $is_ex === false && $count >= 3) {
$classpath .= strtolower(implode('/', array_slice($arrClassNamePart, 1, -1))) . '/';
} elseif ($arrClassNamePart[0] === 'SC') {
Expand Down
22 changes: 22 additions & 0 deletions e2e-tests/test/admin/customer/edit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test, expect } from '@playwright/test';
import PlaywrightConfig from '../../../../playwright.config';
import { ZapClient, ContextType } from '../../../utils/ZapClient';
const zapClient = new ZapClient();

const url = `${PlaywrightConfig.use.baseURL}/admin/customer/edit.php`;
test.describe.serial('会員登録画面のテストをします', () => {
test.beforeAll(async () => {
await zapClient.startSession(ContextType.Admin, 'admin_customer_edit')
.then(async () => expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy());
});

test('会員登録画面のテストをします', async ( { page }) => {
await page.goto(url);
await expect(page.locator('h1')).toContainText(/会員登録/);
});

test('LC_Page_Admin_Customer_Edit_Ex クラスのテストをします @extends', async ( { page }) => {
await page.goto(url);
await expect(page.locator('h1')).toContainText(/カスタマイズ/);
});
});
24 changes: 12 additions & 12 deletions e2e-tests/test/admin/home.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { test, expect, chromium, Page } from '@playwright/test';
import { ADMIN_DIR } from '../../config/default.config';
import { ZapClient, ContextType } from '../../utils/ZapClient';
const zapClient = new ZapClient();

const url = `/${ADMIN_DIR}index.php`;
const url = `/${ADMIN_DIR}/home.php`;

test.describe.serial('管理画面に正常にログインできるか確認します', () => {
test.describe.serial('管理画面Homeの確認をします', () => {
let page: Page;
test.beforeAll(async () => {
await zapClient.startSession(ContextType.Admin, 'admin_home')
.then(async () => expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy());
const browser = await chromium.launch();

page = await browser.newPage();
await page.goto(url);
});

test('ログイン画面を確認します', async () => {
await expect(page.locator('#login-form')).toContainText(/LOGIN/);
});

test('ログインします', async () => {
await page.fill('input[name=login_id]', 'admin');
await page.fill('input[name=password]', 'password');
await page.click('text=LOGIN');
test('システム情報を確認します', async ({ page }) => {
await page.goto(url);
await expect(page.locator('.shop-info >> nth=0 >> tr >> nth=0 >> td')).toContainText('2.17');
});

test('ログインしたのを確認します', async () => {
await expect(page.locator('#site-check')).toContainText('ログイン : 管理者 様');
test('LC_Page_Admin_Home_Ex クラスのテストをします @extends', async ({ page }) => {
await page.goto(url);
await expect(page.locator('.shop-info >> nth=0 >> tr >> nth=1 >> td')).toContainText('PHP_VERSION_ID');
});
});
28 changes: 28 additions & 0 deletions e2e-tests/test/admin/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { test, expect, chromium, Page } from '@playwright/test';
import { ADMIN_DIR } from '../../config/default.config';

const url = `/${ADMIN_DIR}index.php`;

test.describe.serial('管理画面に正常にログインできるか確認します', () => {
let page: Page;
test.beforeAll(async () => {
const browser = await chromium.launch();

page = await browser.newPage();
await page.goto(url);
});

test('ログイン画面を確認します', async () => {
await expect(page.locator('#login-form')).toContainText(/LOGIN/);
});

test('ログインします', async () => {
await page.fill('input[name=login_id]', 'admin');
await page.fill('input[name=password]', 'password');
await page.click('text=LOGIN');
});

test('ログインしたのを確認します', async () => {
await expect(page.locator('#site-check')).toContainText('ログイン : 管理者 様');
});
});
5 changes: 5 additions & 0 deletions e2e-tests/test/admin/total/total.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,9 @@ test.describe.serial('売上集計画面を確認をします', () => {
.then(file => expect(file.split('\r\n').length).toBeGreaterThanOrEqual(2));
});
});

test('LC_Page_Admin_Total_Ex クラスのテストをします @extends', async ( { page }) => {
await page.goto(url);
await expect(page.locator('h1')).toContainText(/カスタマイズ/);
});
});
30 changes: 30 additions & 0 deletions e2e-tests/test/front_guest/welcome.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { test, expect, chromium, Page } from '@playwright/test';

const url = '/index.php';

test.describe.serial('トップページのテストをします', () => {
let page: Page;
test.beforeAll(async () => {
const browser = await chromium.launch();
page = await browser.newPage();
await page.goto(url);
});

test('TOPページが正常に見られているかを確認します', async () => {
await expect(page.locator('#site_description')).toHaveText('EC-CUBE発!世界中を旅して見つけた立方体グルメを立方隊長が直送!');
await expect(page.locator('#main_image')).toBeVisible();
});

test('body の class 名出力を確認します', async () => {
await expect(page.locator('body')).toHaveAttribute('class', 'LC_Page_Index');
});

test('システムエラーが出ていないのを確認します', async () => {
await expect(page.locator('.error')).not.toBeVisible();
});

test('LC_Page_Index_Ex クラスのテストをします @extends', async ( { page }) => {
await page.goto(url);
await expect(page).toHaveTitle(/カスタマイズ/);
});
});
22 changes: 22 additions & 0 deletions e2e-tests/test/front_login/mypage/change.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test, expect } from '@playwright/test';
import PlaywrightConfig from '../../../../playwright.config';
import { ZapClient, ContextType } from '../../../utils/ZapClient';
const zapClient = new ZapClient();

const url = `${PlaywrightConfig.use.baseURL}/mypage/change.php`;
test.describe.serial('会員登録内容変更画面のテストをします', () => {
test.beforeAll(async () => {
await zapClient.startSession(ContextType.FrontLogin, 'front_login_mypage_change')
.then(async () => expect(await zapClient.isForcedUserModeEnabled()).toBeTruthy());
});

test('会員登録内容変更画面のテストをします', async ( { page }) => {
await page.goto(url);
await expect(page).toHaveTitle(/会員登録内容変更/);
});

test('LC_Page_Mypage_Change_Ex クラスのテストをします @extends', async ( { page }) => {
await page.goto(url);
await expect(page).toHaveTitle(/カスタマイズ/);
});
});
5 changes: 5 additions & 0 deletions e2e-tests/test/front_login/welcome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ test.describe.serial('トップページのテストをします', () => {
test('システムエラーが出ていないのを確認します', async () => {
await expect(page.locator('.error')).not.toBeVisible();
});

test('LC_Page_Index_Ex クラスのテストをします @extends', async ( { page }) => {
await page.goto(url);
await expect(page).toHaveTitle(/カスタマイズ/);
});
});
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"scripts": {
"lint:javascript": "eslint --fix data/*.js",
"lint:typescript": "eslint --fix --ext .ts e2e-tests",
"test:e2e": "playwright test --grep-invert @attack",
"test:attack": "playwright test"
"test:e2e": "playwright test --grep-invert '(@attack|@extends)'",
"test:e2e-extends": "playwright test --grep @extends",
"test:attack": "playwright test --grep-invert @extends"
}
}
14 changes: 14 additions & 0 deletions tests/class/fixtures/page_extends/LC_Page_Index_Ex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
class LC_Page_Index_Ex extends LC_Page_Index
{
public function init()
{
parent::init();
$this->tpl_subtitle = '(カスタマイズ)';
}

public function process()
{
parent::process();
}
}
21 changes: 21 additions & 0 deletions tests/class/fixtures/page_extends/admin/LC_Page_Admin_Home_Ex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
class LC_Page_Admin_Home_Ex extends LC_Page_Admin_Home
{
public function init()
{
parent::init();
}

public function process()
{
parent::process();
}

/**
* @override
*/
public function lfGetPHPVersion()
{
return 'PHP_VERSION_ID: '.PHP_VERSION_ID;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
class LC_Page_Admin_Customer_Edit_Ex extends LC_Page_Admin_Customer_Edit
{
public function init()
{
parent::init();
$this->tpl_subtitle = '会員登録(カスタマイズ)';
}

public function process()
{
parent::process();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
class LC_Page_Admin_Total_Ex extends LC_Page_Admin_Total
{
public function init()
{
parent::init();
$this->tpl_maintitle = '売上集計(カスタマイズ)';
}

public function process()
{
parent::process();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
class LC_Page_Mypage_Change_Ex extends LC_Page_Mypage_Change
{
public function init()
{
parent::init();
$this->tpl_subtitle = '会員登録内容変更(カスタマイズ)';
}

public function process()
{
parent::process();
}
}