setup-php/__tests__/extensions.test.ts

120 lines
4.6 KiB
TypeScript
Raw Normal View History

2019-10-08 19:42:54 +07:00
import * as extensions from '../src/extensions';
describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension(
2020-03-14 09:12:02 +07:00
'Xdebug, pcov, sqlite, phalcon4, ast-beta',
2019-12-02 22:13:45 +07:00
'7.4',
2019-10-08 19:42:54 +07:00
'win32'
);
expect(win32).toContain('Add-Extension xdebug');
expect(win32).toContain('Add-Extension pcov');
2020-03-14 09:12:02 +07:00
expect(win32).toContain('Add-Extension sqlite3');
2019-12-26 20:01:18 +07:00
expect(win32).toContain('phalcon.ps1 phalcon4');
expect(win32).toContain('Add-Extension ast beta');
2019-10-08 19:42:54 +07:00
win32 = await extensions.addExtension('xdebug2', '7.2', 'win32');
2020-11-27 01:20:49 +07:00
expect(win32).toContain('Add-Extension xdebug stable 2.9.8');
2020-03-16 08:08:50 +07:00
win32 = await extensions.addExtension('mysql', '7.4', 'win32');
expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd');
win32 = await extensions.addExtension('mysql', '8.0', 'win32');
expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd');
win32 = await extensions.addExtension('mysql', '5.6', 'win32');
expect(win32).toContain('Add-Extension mysql');
expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd');
2019-10-17 03:11:13 +07:00
win32 = await extensions.addExtension(
'phalcon3, does_not_exist',
2019-10-17 03:11:13 +07:00
'7.2',
'win32',
true
);
2019-12-26 20:01:18 +07:00
expect(win32).toContain('phalcon.ps1 phalcon3');
expect(win32).toContain('Add-Extension does_not_exist');
2019-10-08 19:42:54 +07:00
win32 = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(win32).toContain('Platform openbsd is not supported');
2019-10-08 19:42:54 +07:00
});
it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension(
2020-03-14 09:12:02 +07:00
'Xdebug, pcov, sqlite, ast-beta, xdebug-alpha',
2019-12-02 22:13:45 +07:00
'7.4',
2019-10-08 19:42:54 +07:00
'linux'
);
2020-03-14 09:12:02 +07:00
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
2019-10-08 19:42:54 +07:00
expect(linux).toContain(
2020-03-14 09:12:02 +07:00
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
2019-10-08 19:42:54 +07:00
);
2020-01-30 13:33:30 +07:00
expect(linux).toContain('add_unstable_extension ast beta extension');
expect(linux).toContain(
'add_unstable_extension xdebug alpha zend_extension'
);
2019-10-08 19:42:54 +07:00
linux = await extensions.addExtension('gearman', '7.0', 'linux');
2021-04-19 02:35:21 +07:00
expect(linux).toContain('gearman.sh');
2019-12-02 22:13:45 +07:00
linux = await extensions.addExtension('xdebug2', '7.2', 'linux');
2020-11-27 01:20:49 +07:00
expect(linux).toContain('add_pecl_extension xdebug 2.9.8 zend_extension');
linux = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(linux).toContain('Platform openbsd is not supported');
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
expect(linux).toContain('phalcon.sh phalcon3 7.3');
expect(linux).toContain('phalcon.sh phalcon4 7.3');
2019-10-08 19:42:54 +07:00
});
it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension(
'Xdebug, pcov, grpc, igbinary, imagick, phalcon3, phalcon4, protobuf, psr, swoole, sqlite, ast-beta',
2019-10-08 19:42:54 +07:00
'7.2',
'darwin'
);
2020-06-19 05:39:13 +07:00
expect(darwin).toContain('add_brew_extension xdebug');
expect(darwin).toContain('add_brew_extension pcov');
expect(darwin).toContain('add_brew_extension grpc');
expect(darwin).toContain('add_brew_extension igbinary');
expect(darwin).toContain('add_brew_extension imagick');
expect(darwin).toContain('add_brew_extension phalcon3');
expect(darwin).toContain('add_brew_extension phalcon4');
expect(darwin).toContain('add_brew_extension protobuf');
expect(darwin).toContain('add_brew_extension psr');
expect(darwin).toContain('add_brew_extension swoole');
2020-08-03 15:54:54 +07:00
expect(darwin).toContain('pecl_install sqlite3');
2020-01-30 13:33:30 +07:00
expect(darwin).toContain('add_unstable_extension ast beta extension');
2019-10-08 19:42:54 +07:00
darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
2020-08-03 15:54:54 +07:00
expect(darwin).toContain('pecl_install pcov');
2019-10-08 19:42:54 +07:00
darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
2020-06-19 05:39:13 +07:00
expect(darwin).toContain('add_brew_extension pcov');
2019-10-08 19:42:54 +07:00
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
2020-06-19 05:39:13 +07:00
expect(darwin).toContain('add_brew_extension xdebug');
2019-10-08 19:42:54 +07:00
2020-01-17 07:21:46 +07:00
darwin = await extensions.addExtension('xdebug', '7.0', 'darwin');
2020-06-19 05:39:13 +07:00
expect(darwin).toContain('add_brew_extension xdebug');
2020-01-17 07:21:46 +07:00
2021-02-22 16:09:22 +07:00
darwin = await extensions.addExtension('xdebug2', '7.2', 'darwin');
expect(darwin).toContain('add_brew_extension xdebug2');
2019-10-08 19:42:54 +07:00
2019-10-17 03:11:13 +07:00
darwin = await extensions.addExtension(
'does_not_exist',
'7.2',
'darwin',
false
);
2019-10-11 06:11:25 +07:00
expect(darwin).toContain('add_extension does_not_exist');
2019-10-08 19:42:54 +07:00
darwin = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(darwin).toContain('Platform openbsd is not supported');
2019-10-08 19:42:54 +07:00
});
});