Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into dependabot/npm_an…
Browse files Browse the repository at this point in the history
…d_yarn/terser-5.14.2
  • Loading branch information
nanasess committed Aug 5, 2022
2 parents 3cc3054 + c8b4836 commit 44427fd
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 29 deletions.
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 @@ -58,11 +64,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
12 changes: 1 addition & 11 deletions data/module/Net/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,6 @@ class Net_URL
*/
var $useBrackets;

/**
* PHP4 Constructor
*
* @see __construct()
*/
function Net_URL($url = null, $useBrackets = true)
{
$this->__construct($url, $useBrackets);
}

/**
* PHP5 Constructor
*
Expand All @@ -127,7 +117,7 @@ function Net_URL($url = null, $useBrackets = true)
* multiple querystrings with the same name
* exist
*/
function __construct($url = null, $useBrackets = true)
public function __construct($url = null, $useBrackets = true)
{
$this->url = $url;
$this->useBrackets = $useBrackets;
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 @@ -309,4 +309,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();
}
}
6 changes: 4 additions & 2 deletions tests/require.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
exit(1);
}

class_exists('FPDI'); // XXX PHPStan が FPDI を見つけてくれないのでロードしておく
class_exists('Smarty'); // XXX PHPStan が Smarty を見つけてくれないのでロードしておく
// XXX PHPStan が見つけてくれないライブラリをロードしておく
class_exists('FPDI');
class_exists('Smarty');
class_exists('MDB2');

if (!class_exists('PHPUnit_Framework_TestCase')) {
class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
Expand Down

0 comments on commit 44427fd

Please sign in to comment.