setup-php/__tests__/extensions.test.ts

261 lines
11 KiB
TypeScript
Raw Permalink 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(
'Xdebug, pcov, sqlite, :intl, phalcon4, pecl_http, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2, sqlsrv-1.2.3preview1',
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-12 06:17:52 +07:00
expect(win32).toContain('Add-Extension sqlite3');
2020-05-07 04:57:00 +07:00
expect(win32).toContain('Remove-Extension intl');
2020-07-26 17:18:19 +07:00
expect(win32).toContain('Add-Phalcon phalcon4');
expect(win32).toContain('Add-Http');
2020-07-26 17:18:19 +07:00
expect(win32).toContain('Add-Ioncube');
2020-08-06 17:03:58 +07:00
expect(win32).toContain('Add-Oci oci8');
expect(win32).toContain('Add-Oci pdo_oci');
expect(win32).toContain('Add-Extension ast beta');
expect(win32).toContain('Add-Extension grpc stable 1.2.3');
2020-02-16 01:55:50 +07:00
expect(win32).toContain('Add-Extension inotify alpha 1.2.3');
expect(win32).toContain('Add-Extension sqlsrv devel 1.2.3');
2019-10-08 19:42:54 +07:00
win32 = await extensions.addExtension('pcov', '5.6', 'win32');
expect(win32).toContain(
'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
);
2020-12-24 19:50:42 +07:00
win32 = await extensions.addExtension('xdebug2', '7.2', 'win32');
expect(win32).toContain('Add-Extension xdebug stable 2.9.8');
2020-03-16 08:23:58 +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.5', '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
);
2020-07-26 17:18:19 +07:00
expect(win32).toContain('Add-Phalcon 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');
2020-02-27 05:59:45 +07:00
win32 = await extensions.addExtension('blackfire', '7.3', 'win32');
2020-07-26 17:18:19 +07:00
expect(win32).toContain('Add-Blackfire blackfire');
2020-02-27 05:59:45 +07:00
win32 = await extensions.addExtension('blackfire-1.31.0', '7.3', 'win32');
2020-07-26 17:18:19 +07:00
expect(win32).toContain('Add-Blackfire blackfire-1.31.0');
win32 = await extensions.addExtension(
'mongodb-mongodb/mongo-php-driver@master',
'7.3',
'win32'
);
expect(win32).toContain(
'Add-Log "$cross" "mongodb-mongodb/mongo-php-driver@master" "mongodb-mongodb/mongo-php-driver@master is not supported on PHP 7.3"'
);
2019-10-08 19:42:54 +07:00
});
it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension(
2020-12-24 19:50:42 +07:00
'Xdebug, pcov, sqlite, :intl, ast, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
2019-12-02 22:13:45 +07:00
'7.4',
2019-10-08 19:42:54 +07:00
'linux'
);
2020-12-24 19:50:42 +07:00
expect(linux).toContain('add_extension xdebug');
2020-11-08 14:36:21 +07:00
expect(linux).toContain('add_extension sqlite3');
2020-05-07 04:57:00 +07:00
expect(linux).toContain('remove_extension intl');
2020-01-30 13:33:30 +07:00
expect(linux).toContain('add_unstable_extension ast beta extension');
2020-03-05 07:28:24 +07:00
expect(linux).toContain('add_pdo_extension mysql');
expect(linux).toContain('add_pdo_extension odbc');
2020-02-23 20:30:40 +07:00
expect(linux).toContain('add_pecl_extension grpc 1.2.3 extension');
2020-01-30 13:33:30 +07:00
expect(linux).toContain(
'add_unstable_extension xdebug alpha zend_extension'
);
2019-10-08 19:42:54 +07:00
linux = await extensions.addExtension('pcov', '5.6', 'linux');
expect(linux).toContain(
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
);
2020-11-16 19:35:08 +07:00
linux = await extensions.addExtension('gearman', '5.6', 'linux');
2020-07-26 17:18:19 +07:00
expect(linux).toContain('add_gearman');
linux = await extensions.addExtension('gearman', '7.4', 'linux');
2020-07-26 17:18:19 +07:00
expect(linux).toContain('add_gearman');
2019-12-02 22:13:45 +07:00
2020-11-16 19:35:08 +07:00
linux = await extensions.addExtension('couchbase', '5.6', 'linux');
expect(linux).toContain('add_couchbase');
linux = await extensions.addExtension('couchbase', '7.4', 'linux');
expect(linux).toContain('add_couchbase');
linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux');
expect(linux).toContain('add_cubrid pdo_cubrid');
linux = await extensions.addExtension('cubrid', '7.4', 'linux');
expect(linux).toContain('add_cubrid cubrid');
2020-12-24 19:50:42 +07:00
linux = await extensions.addExtension('xdebug2', '7.2', 'linux');
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');
2020-07-26 17:18:19 +07:00
expect(linux).toContain('add_phalcon phalcon3');
expect(linux).toContain('add_phalcon phalcon4');
2020-07-19 12:39:45 +07:00
linux = await extensions.addExtension('ioncube', '7.3', 'linux');
2020-07-26 17:18:19 +07:00
expect(linux).toContain('add_ioncube');
2020-07-19 12:39:45 +07:00
2020-12-14 14:22:00 +07:00
linux = await extensions.addExtension('geos', '7.3', 'linux');
expect(linux).toContain('add_geos');
linux = await extensions.addExtension('pecl_http', '7.3', 'linux');
expect(linux).toContain('add_http');
linux = await extensions.addExtension('http-1.2.3', '7.3', 'linux');
expect(linux).toContain('add_http http-1.2.3');
2020-07-15 11:15:40 +07:00
linux = await extensions.addExtension('oci8, pdo_oci', '7.3', 'linux');
2020-07-26 17:18:19 +07:00
expect(linux).toContain('add_oci oci8');
expect(linux).toContain('add_oci pdo_oci');
2020-07-15 11:15:40 +07:00
linux = await extensions.addExtension('blackfire', '7.3', 'linux');
2020-07-26 17:18:19 +07:00
expect(linux).toContain('add_blackfire blackfire');
linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux');
2020-07-26 17:18:19 +07:00
expect(linux).toContain('add_blackfire blackfire-1.31.0');
2020-09-02 21:48:37 +07:00
linux = await extensions.addExtension('intl-65.1', '5.6', 'linux');
expect(linux).toContain('add_intl intl-65.1');
linux = await extensions.addExtension('intl-67.1', '7.3', 'linux');
expect(linux).toContain('add_intl intl-67.1');
linux = await extensions.addExtension('intl-68.2', '8.0', 'linux');
expect(linux).toContain('add_intl intl-68.2');
linux = await extensions.addExtension(
'mongodb-mongodb/mongo-php-driver@master',
'7.3',
'linux'
);
expect(linux).toContain(
'add_extension_from_github mongodb mongodb mongo-php-driver master'
);
2019-10-08 19:42:54 +07:00
});
it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension(
'amqp, Xdebug, pcov, grpc, igbinary, imagick, imap, msgpack, protobuf, redis, swoole, sqlite, oci8, pdo_oci, :intl, ast-beta, grpc-1.2.3',
2019-10-08 19:42:54 +07:00
'7.2',
'darwin'
);
expect(darwin).toContain('add_brew_extension amqp extension');
2020-11-08 14:36:21 +07:00
expect(darwin).toContain('add_brew_extension xdebug zend_extension');
expect(darwin).toContain('add_brew_extension pcov extension');
expect(darwin).toContain('add_brew_extension grpc extension');
expect(darwin).toContain('add_brew_extension igbinary extension');
expect(darwin).toContain('add_brew_extension imagick extension');
expect(darwin).toContain('add_brew_extension imap extension');
expect(darwin).toContain('add_brew_extension msgpack extension');
2020-11-08 14:36:21 +07:00
expect(darwin).toContain('add_brew_extension protobuf extension');
expect(darwin).toContain('add_brew_extension redis extension');
2020-11-08 14:36:21 +07:00
expect(darwin).toContain('add_brew_extension swoole extension');
expect(darwin).toContain('add_extension sqlite3');
2020-05-07 04:57:00 +07:00
expect(darwin).toContain('remove_extension intl');
2020-01-30 13:33:30 +07:00
expect(darwin).toContain('add_unstable_extension ast beta extension');
2020-02-23 20:30:40 +07:00
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
2019-10-08 19:42:54 +07:00
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
2020-07-26 17:18:19 +07:00
expect(darwin).toContain('add_phalcon phalcon3');
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
2020-07-26 17:18:19 +07:00
expect(darwin).toContain('add_phalcon phalcon4');
2020-11-16 19:35:08 +07:00
darwin = await extensions.addExtension('couchbase', '5.6', 'darwin');
expect(darwin).toContain('add_couchbase');
darwin = await extensions.addExtension('couchbase', '7.3', 'darwin');
expect(darwin).toContain('add_couchbase');
2020-07-19 12:39:45 +07:00
darwin = await extensions.addExtension('ioncube', '7.3', 'darwin');
2020-07-26 17:18:19 +07:00
expect(darwin).toContain('add_ioncube');
2020-07-19 12:39:45 +07:00
2020-12-14 14:22:00 +07:00
darwin = await extensions.addExtension('geos', '7.3', 'darwin');
expect(darwin).toContain('add_geos');
darwin = await extensions.addExtension('pecl_http', '7.3', 'darwin');
expect(darwin).toContain('add_http');
darwin = await extensions.addExtension('http-1.2.3', '7.3', 'darwin');
expect(darwin).toContain('add_http http-1.2.3');
2020-07-15 11:15:40 +07:00
darwin = await extensions.addExtension('oci8, pdo_oci', '7.3', 'darwin');
2020-07-26 17:18:19 +07:00
expect(darwin).toContain('add_oci oci8');
expect(darwin).toContain('add_oci pdo_oci');
2020-07-15 11:15:40 +07:00
2019-10-08 19:42:54 +07:00
darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
expect(darwin).toContain(
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
);
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
2019-10-08 19:42:54 +07:00
darwin = await extensions.addExtension('xdebug', '7.2', '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-12-24 19:50:42 +07:00
darwin = await extensions.addExtension('xdebug2', '7.2', 'darwin');
expect(darwin).toContain('add_brew_extension xdebug2');
darwin = await extensions.addExtension('imagick', '5.5', 'darwin');
2020-11-08 14:36:21 +07:00
expect(darwin).toContain('add_extension imagick');
2020-01-21 02:36:31 +07:00
2020-02-27 05:59:45 +07:00
darwin = await extensions.addExtension('blackfire', '7.3', 'darwin');
2020-07-26 17:18:19 +07:00
expect(darwin).toContain('add_blackfire blackfire');
2020-02-27 05:59:45 +07:00
darwin = await extensions.addExtension('blackfire-1.31.0', '7.3', 'darwin');
2020-07-26 17:18:19 +07:00
expect(darwin).toContain('add_blackfire blackfire-1.31.0');
2020-02-27 05:59:45 +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');
darwin = await extensions.addExtension(
'mongodb-mongodb/mongo-php-driver@master',
'7.3',
'darwin'
);
expect(darwin).toContain(
'add_extension_from_github mongodb mongodb mongo-php-driver master'
);
2019-10-08 19:42:54 +07:00
});
});