setup-php/__tests__/coverage.test.ts

111 lines
4.0 KiB
TypeScript
Raw Normal View History

2019-10-08 19:42:54 +07:00
import * as coverage from '../src/coverage';
describe('Config tests', () => {
it('checking addCoverage with PCOV on windows', async () => {
2020-01-26 17:45:39 +07:00
let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32');
2020-06-20 07:55:19 +07:00
expect(win32).toContain('Add-Extension pcov');
expect(win32).toContain('Disable-Extension xdebug');
2019-10-08 19:42:54 +07:00
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
2019-10-17 03:11:13 +07:00
expect(win32).toContain('PHP 7.1 or newer is required');
2019-10-08 19:42:54 +07:00
win32 = await coverage.addCoverage('pcov', '5.6', 'win32');
2019-10-17 03:11:13 +07:00
expect(win32).toContain('PHP 7.1 or newer is required');
2019-10-08 19:42:54 +07:00
});
it('checking addCoverage with PCOV on linux', async () => {
2019-11-24 03:34:12 +07:00
const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux');
2019-12-26 20:01:18 +07:00
expect(linux).toContain('add_extension pcov');
expect(linux).toContain('disable_extension xdebug');
2019-10-08 19:42:54 +07:00
});
it('checking addCoverage with PCOV on darwin', async () => {
2019-11-24 03:34:12 +07:00
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
2020-11-08 14:36:21 +07:00
expect(darwin).toContain('add_brew_extension pcov');
expect(darwin).toContain('disable_extension xdebug');
2019-10-08 19:42:54 +07:00
});
it('checking addCoverage with Xdebug on windows', async () => {
2019-12-09 16:24:14 +07:00
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
2020-06-20 07:55:19 +07:00
expect(win32).toContain('Add-Extension xdebug');
2019-10-08 19:42:54 +07:00
});
2020-12-24 19:50:42 +07:00
it('checking addCoverage with Xdebug3 on windows', async () => {
const win32: string = await coverage.addCoverage('xdebug3', '7.4', 'win32');
expect(win32).toContain('Add-Extension xdebug');
2020-06-20 07:55:19 +07:00
});
2020-12-24 19:50:42 +07:00
it('checking addCoverage with Xdebug2 on windows', async () => {
const win32: string = await coverage.addCoverage('xdebug2', '7.4', 'win32');
expect(win32).toContain('Add-Extension xdebug stable 2.9.8');
2019-10-08 19:42:54 +07:00
});
2020-06-19 16:17:34 +07:00
it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux');
expect(linux).toContain('add_extension xdebug');
});
it('checking addCoverage with Xdebug3 on linux', async () => {
2020-12-24 19:50:42 +07:00
const linux: string = await coverage.addCoverage('xdebug3', '8.0', 'linux');
expect(linux).toContain('add_extension xdebug');
});
2020-12-24 19:50:42 +07:00
it('checking addCoverage with Xdebug2 on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug2', '7.4', 'linux');
expect(linux).toContain('add_pecl_extension xdebug 2.9.8 zend_extension');
});
2019-10-08 19:42:54 +07:00
it('checking addCoverage with Xdebug on darwin', async () => {
2019-11-24 03:34:12 +07:00
const darwin: string = await coverage.addCoverage(
'xdebug',
'7.4',
'darwin'
);
2020-11-08 14:36:21 +07:00
expect(darwin).toContain('add_brew_extension xdebug');
2020-12-24 19:50:42 +07:00
});
it('checking addCoverage with Xdebug3 on darwin', async () => {
const darwin: string = await coverage.addCoverage(
'xdebug3',
'7.4',
'darwin'
);
expect(darwin).toContain('add_brew_extension xdebug');
});
it('checking addCoverage with Xdebug2 on darwin', async () => {
const darwin: string = await coverage.addCoverage(
'xdebug2',
'7.4',
'darwin'
);
expect(darwin).toContain('add_brew_extension xdebug2');
2019-12-09 16:24:14 +07:00
});
2019-10-08 19:42:54 +07:00
it('checking disableCoverage windows', async () => {
2019-11-24 03:34:12 +07:00
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
expect(win32).toContain('Disable-Extension xdebug');
expect(win32).toContain('Disable-Extension pcov');
2019-10-08 19:42:54 +07:00
});
it('checking disableCoverage on linux', async () => {
2019-11-24 03:34:12 +07:00
const linux: string = await coverage.addCoverage('none', '7.4', 'linux');
expect(linux).toContain('disable_extension xdebug');
expect(linux).toContain('disable_extension pcov');
2019-10-08 19:42:54 +07:00
});
it('checking disableCoverage on darwin', async () => {
2019-11-24 03:34:12 +07:00
const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
expect(darwin).toContain('disable_extension xdebug');
expect(darwin).toContain('disable_extension pcov');
2019-10-08 19:42:54 +07:00
});
it('checking no or invalid coverage driver', async () => {
let nocov: string = await coverage.addCoverage('nocov', '7.x', 'any');
expect(nocov).toEqual('');
nocov = await coverage.addCoverage('', '7.x', 'any');
expect(nocov).toEqual('');
});
});