2019-10-30 10:46:37 +07:00
|
|
|
import * as install from '../src/install';
|
2020-10-04 20:08:22 +07:00
|
|
|
import * as utils from '../src/utils';
|
2019-10-30 10:46:37 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mock install.ts
|
|
|
|
*/
|
|
|
|
jest.mock('../src/install', () => ({
|
2022-01-30 10:15:11 +07:00
|
|
|
getScript: jest
|
|
|
|
.fn()
|
|
|
|
.mockImplementation(async (os: string): Promise<string> => {
|
|
|
|
const filename = os + (await utils.scriptExtension(os));
|
|
|
|
const version: string = await utils.parseVersion(
|
|
|
|
await utils.getInput('php-version', true)
|
|
|
|
);
|
|
|
|
const ini_file: string = await utils.parseIniFile(
|
|
|
|
await utils.getInput('ini-file', false)
|
|
|
|
);
|
|
|
|
const extension_csv: string = process.env['extensions'] || '';
|
|
|
|
const ini_values_csv: string = process.env['ini-values'] || '';
|
|
|
|
const coverage_driver: string = process.env['coverage'] || '';
|
|
|
|
const tools_csv: string = process.env['tools'] || '';
|
|
|
|
let script = await utils.joins(filename, version, ini_file);
|
|
|
|
script += extension_csv ? ' install extensions' : '';
|
|
|
|
script += tools_csv ? ' add_tool' : '';
|
|
|
|
script += coverage_driver ? ' set coverage driver' : '';
|
|
|
|
script += ini_values_csv ? ' edit php.ini' : '';
|
|
|
|
return script;
|
|
|
|
}),
|
2021-05-31 06:51:18 +07:00
|
|
|
run: jest.fn().mockImplementation(async (): Promise<string> => {
|
2022-01-29 06:59:58 +07:00
|
|
|
const os: string = process.env['RUNNER_OS'] || '';
|
|
|
|
const tool = await utils.scriptTool(os);
|
2022-01-30 10:15:11 +07:00
|
|
|
return tool + (await install.getScript(os));
|
2021-05-31 06:51:18 +07:00
|
|
|
})
|
2019-10-30 10:46:37 +07:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('Install', () => {
|
2021-10-09 19:00:06 +07:00
|
|
|
it.each`
|
2022-01-25 15:13:49 +07:00
|
|
|
version | os | extension_csv | ini_file | ini_values_csv | coverage_driver | tools | output
|
2022-01-30 10:15:11 +07:00
|
|
|
${'7.3'} | ${'darwin'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 7.3 production'}
|
|
|
|
${'7.3'} | ${'darwin'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${''} | ${'bash darwin.sh 7.3 development install extensions set coverage driver edit php.ini'}
|
|
|
|
${'7.4.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 7.4 none'}
|
|
|
|
${'8'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.0 production'}
|
|
|
|
${'8.0'} | ${'darwin'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.0 development'}
|
|
|
|
${'8.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.1 none'}
|
|
|
|
${'7.3'} | ${'linux'} | ${''} | ${'invalid'} | ${''} | ${''} | ${''} | ${'bash linux.sh 7.3 production'}
|
|
|
|
${'7.3'} | ${'linux'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${'phpunit'} | ${'bash linux.sh 7.3 development install extensions add_tool set coverage driver edit php.ini'}
|
|
|
|
${'latest'} | ${'linux'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash linux.sh 8.1 none'}
|
|
|
|
${'7.0'} | ${'win32'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'pwsh win32.ps1 7.0 production'}
|
|
|
|
${'7.3'} | ${'win32'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'pwsh win32.ps1 7.3 development'}
|
|
|
|
${'7.3'} | ${'win32'} | ${'a, b'} | ${'none'} | ${'a=b'} | ${'x'} | ${''} | ${'pwsh win32.ps1 7.3 none install extensions set coverage driver edit php.ini'}
|
2021-10-09 19:00:06 +07:00
|
|
|
`(
|
2021-10-09 20:14:47 +07:00
|
|
|
'Test install on $os for $version with extensions=$extension_csv, ini_values=$ini_values_csv, coverage_driver=$coverage_driver, tools=$tools',
|
2021-10-09 19:00:06 +07:00
|
|
|
async ({
|
|
|
|
version,
|
2021-10-09 20:14:47 +07:00
|
|
|
os,
|
2021-10-09 19:00:06 +07:00
|
|
|
extension_csv,
|
2022-01-25 15:13:49 +07:00
|
|
|
ini_file,
|
2021-10-09 19:00:06 +07:00
|
|
|
ini_values_csv,
|
|
|
|
coverage_driver,
|
|
|
|
tools,
|
|
|
|
output
|
|
|
|
}) => {
|
2022-01-30 10:15:11 +07:00
|
|
|
process.env['php-version'] = version.toString();
|
|
|
|
process.env['RUNNER_OS'] = os;
|
|
|
|
process.env['extensions'] = extension_csv;
|
|
|
|
process.env['ini-file'] = ini_file;
|
|
|
|
process.env['ini-values'] = ini_values_csv;
|
|
|
|
process.env['coverage'] = coverage_driver;
|
|
|
|
process.env['tools'] = tools;
|
2021-10-09 20:31:59 +07:00
|
|
|
expect(await install.run()).toBe(output);
|
2021-10-09 19:00:06 +07:00
|
|
|
}
|
|
|
|
);
|
2019-10-30 10:46:37 +07:00
|
|
|
});
|