2021-10-09 09:41:39 +07:00
import * as fs from 'fs' ;
2019-10-08 19:42:54 +07:00
import * as extensions from '../src/extensions' ;
describe ( 'Extension tests' , ( ) = > {
2021-10-06 02:35:47 +07:00
it . each `
extension | version | output
$ { 'none' } | $ { '7.4' } | $ { 'Disable-AllShared' }
$ { ':intl' } | $ { '7.4' } | $ { 'Disable-Extension intl' }
$ { 'ast-beta' } | $ { '7.4' } | $ { 'Add-Extension ast beta' }
2021-10-08 23:54:17 +07:00
$ { 'blackfire' } | $ { '7.3' } | $ { 'Add-Blackfire blackfire' }
$ { 'blackfire-1.31.0' } | $ { '7.3' } | $ { 'Add-Blackfire blackfire-1.31.0' }
2021-10-06 02:35:47 +07:00
$ { 'grpc-1.2.3' } | $ { '7.4' } | $ { 'Add-Extension grpc stable 1.2.3' }
$ { 'inotify-1.2.3alpha2' } | $ { '7.4' } | $ { 'Add-Extension inotify alpha 1.2.3' }
2021-10-08 23:54:17 +07:00
$ { 'ioncube' } | $ { '7.4' } | $ { 'Add-Ioncube' }
$ { 'mongodb-mongodb/mongo-php-driver@master' } | $ { '7.3' } | $ { 'Add-Log "$cross" "mongodb-mongodb/mongo-php-driver@master" "mongodb-mongodb/mongo-php-driver@master is not supported on PHP 7.3"' }
$ { 'mysql' } | $ { '7.4' } | $ { 'Add-Extension mysqli\nAdd-Extension mysqlnd' }
$ { 'mysql' } | $ { '5.5' } | $ { 'Add-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd' }
$ { 'oci8' } | $ { '7.4' } | $ { 'Add-Oci oci8' }
2021-10-06 02:35:47 +07:00
$ { 'pcov' } | $ { '5.6' } | $ { 'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"' }
2021-10-08 23:54:17 +07:00
$ { 'pdo_oci' } | $ { '7.4' } | $ { 'Add-Oci pdo_oci' }
$ { 'pecl_http' } | $ { '7.4' } | $ { 'Add-Http' }
2021-10-06 02:35:47 +07:00
$ { 'phalcon3' } | $ { '7.2' } | $ { 'Add-Phalcon phalcon3' }
2021-10-08 23:54:17 +07:00
$ { 'phalcon4' } | $ { '7.4' } | $ { 'Add-Phalcon phalcon4' }
$ { 'sqlite' } | $ { '7.4' } | $ { 'Add-Extension sqlite3' }
$ { 'sqlsrv-1.2.3preview1' } | $ { '7.4' } | $ { 'Add-Extension sqlsrv devel 1.2.3' }
$ { 'Xdebug' } | $ { '7.4' } | $ { 'Add-Extension xdebug' }
$ { 'xdebug2' } | $ { '7.2' } | $ { 'Add-Extension xdebug stable 2.9.8' }
2023-01-22 03:34:12 +07:00
$ { 'zephir_parser' } | $ { '7.2' } | $ { 'Add-ZephirParser zephir_parser' }
2021-10-09 09:41:39 +07:00
` (
2021-10-06 02:35:47 +07:00
'checking addExtensionOnWindows for extension $extension on version $version' ,
async ( { extension , version , output } ) = > {
expect (
await extensions . addExtension ( extension , version , 'win32' )
) . toContain ( output ) ;
}
) ;
it . each `
extension | version | output
$ { 'none' } | $ { '7.4' } | $ { 'disable_all_shared' }
$ { ':intl' } | $ { '7.4' } | $ { 'disable_extension intl' }
$ { 'ast-beta' } | $ { '7.4' } | $ { 'add_unstable_extension ast beta extension' }
2021-10-08 23:54:17 +07:00
$ { 'blackfire' } | $ { '7.3' } | $ { 'add_blackfire blackfire' }
$ { 'blackfire-1.31.0' } | $ { '7.3' } | $ { 'add_blackfire blackfire-1.31.0' }
2021-10-06 02:35:47 +07:00
$ { 'couchbase' } | $ { '7.4' } | $ { 'add_couchbase' }
2021-10-08 23:54:17 +07:00
$ { 'gearman' } | $ { '5.6' } | $ { 'add_gearman' }
2021-10-06 02:35:47 +07:00
$ { 'geos' } | $ { '7.3' } | $ { 'add_geos' }
2021-10-08 23:54:17 +07:00
$ { 'grpc-1.2.3' } | $ { '7.4' } | $ { 'add_pecl_extension grpc 1.2.3 extension' }
2021-10-06 02:35:47 +07:00
$ { 'http-1.2.3' } | $ { '7.3' } | $ { 'add_http http-1.2.3' }
$ { 'intl-65.1' } | $ { '5.6' } | $ { 'add_intl intl-65.1' }
2021-10-08 23:54:17 +07:00
$ { 'ioncube' } | $ { '7.3' } | $ { 'add_ioncube' }
2023-05-24 17:26:18 +07:00
$ { 'memcache-8.2' } | $ { '8.2' } | $ { 'add_pecl_extension memcache 8.2 extension' }
2021-10-06 02:35:47 +07:00
$ { 'mongodb-mongodb/mongo-php-driver@master' } | $ { '7.3' } | $ { 'add_extension_from_source mongodb https://github.com mongodb mongo-php-driver master extension' }
2021-10-08 23:54:17 +07:00
$ { 'oci8' } | $ { '7.3' } | $ { 'add_oci oci8' }
$ { 'pcov' } | $ { '5.6' } | $ { 'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6' }
$ { 'pdo-odbc' } | $ { '7.4' } | $ { 'add_pdo_extension odbc' }
$ { 'pdo_cubrid' } | $ { '7.0' } | $ { 'add_cubrid pdo_cubrid' }
$ { 'pdo_cubrid' } | $ { '7.4' } | $ { 'add_pdo_extension cubrid' }
$ { 'pdo_mysql' } | $ { '7.4' } | $ { 'add_pdo_extension mysql' }
$ { 'pdo_oci' } | $ { '7.3' } | $ { 'add_oci pdo_oci' }
2022-01-31 19:07:26 +07:00
$ { 'pdo_sqlsrv' } | $ { '7.4' } | $ { 'add_sqlsrv pdo_sqlsrv' }
2021-10-08 23:54:17 +07:00
$ { 'pecl_http' } | $ { '7.3' } | $ { 'add_http' }
$ { 'phalcon3' } | $ { '7.3' } | $ { 'add_phalcon phalcon3' }
2023-01-12 17:44:06 +07:00
$ { 'relay' } | $ { '7.4' } | $ { 'add_relay relay' }
$ { 'relay-v1.2.3' } | $ { '7.4' } | $ { 'add_relay relay-v1.2.3' }
2021-10-08 23:54:17 +07:00
$ { 'sqlite' } | $ { '7.4' } | $ { 'add_extension sqlite3' }
2021-12-08 06:26:29 +07:00
$ { 'sqlsrv-1.2.3-beta1' } | $ { '7.4' } | $ { 'add_pecl_extension sqlsrv 1.2.3beta1 extension' }
2021-10-08 23:54:17 +07:00
$ { 'Xdebug' } | $ { '7.4' } | $ { 'add_extension xdebug' }
$ { 'xdebug-alpha' } | $ { '7.4' } | $ { 'add_unstable_extension xdebug alpha zend_extension' }
$ { 'xdebug2' } | $ { '7.2' } | $ { 'add_pecl_extension xdebug 2.9.8 zend_extension' }
2023-01-22 03:34:12 +07:00
$ { 'zephir_parser-1.2.3' } | $ { '7.2' } | $ { 'add_zephir_parser zephir_parser-1.2.3' }
2021-10-08 21:32:42 +07:00
` (
'checking addExtensionOnLinux for extension $extension on version $version' ,
async ( { extension , version , output } ) = > {
expect (
await extensions . addExtension ( extension , version , 'linux' )
) . toContain ( output ) ;
}
) ;
2021-01-21 17:37:11 +07:00
2021-10-08 21:32:42 +07:00
it . each `
extension | version | output
$ { 'none' } | $ { '7.2' } | $ { 'disable_all_shared' }
$ { ':intl' } | $ { '7.2' } | $ { 'disable_extension intl' }
$ { 'ast-beta' } | $ { '7.2' } | $ { 'add_unstable_extension ast beta extension' }
2021-10-08 23:54:17 +07:00
$ { 'blackfire' } | $ { '7.3' } | $ { 'add_blackfire blackfire' }
$ { 'blackfire-1.31.0' } | $ { '7.3' } | $ { 'add_blackfire blackfire-1.31.0' }
2021-10-08 21:32:42 +07:00
$ { 'couchbase' } | $ { '5.6' } | $ { 'add_couchbase' }
2021-10-08 23:54:17 +07:00
$ { 'does_not_exist' } | $ { '7.2' } | $ { 'add_extension does_not_exist' }
2021-10-08 21:32:42 +07:00
$ { 'geos' } | $ { '7.3' } | $ { 'add_geos' }
2021-10-08 23:54:17 +07:00
$ { 'grpc-1.2.3' } | $ { '7.2' } | $ { 'add_pecl_extension grpc 1.2.3 extension' }
2021-10-08 21:32:42 +07:00
$ { 'http-1.2.3' } | $ { '7.3' } | $ { 'add_http http-1.2.3' }
2021-10-08 23:54:17 +07:00
$ { 'imagick' } | $ { '5.5' } | $ { 'add_extension imagick' }
$ { 'ioncube' } | $ { '7.3' } | $ { 'add_ioncube' }
$ { 'mongodb-mongodb/mongo-php-driver@master' } | $ { '7.2' } | $ { 'add_extension_from_source mongodb https://github.com mongodb mongo-php-driver master extension' }
2021-10-08 21:32:42 +07:00
$ { 'oci8' } | $ { '7.3' } | $ { 'add_oci oci8' }
$ { 'pcov' } | $ { '5.6' } | $ { 'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"' }
2021-10-08 23:54:17 +07:00
$ { 'pdo_oci' } | $ { '7.3' } | $ { 'add_oci pdo_oci' }
$ { 'pecl_http' } | $ { '7.3' } | $ { 'add_http' }
2023-01-12 17:44:06 +07:00
$ { 'relay-1.2.3' } | $ { '7.4' } | $ { 'add_relay relay-1.2.3' }
2021-10-08 23:54:17 +07:00
$ { 'sqlite' } | $ { '7.2' } | $ { 'add_extension sqlite3' }
2023-01-22 03:34:12 +07:00
$ { 'zephir_parser-v1.2.3' } | $ { '7.2' } | $ { 'add_zephir_parser zephir_parser-v1.2.3' }
2021-10-09 09:41:39 +07:00
` (
2021-10-08 21:32:42 +07:00
'checking addExtensionOnDarwin for extension $extension on version $version' ,
async ( { extension , version , output } ) = > {
expect (
await extensions . addExtension ( extension , version , 'darwin' )
) . toContain ( output ) ;
}
) ;
2021-10-08 21:58:41 +07:00
2021-10-09 09:41:39 +07:00
const data : string [ ] [ ] = fs
. readFileSync ( 'src/configs/brew_extensions' )
. toString ( )
. split ( /\r?\n/ )
. filter ( Boolean )
. map ( line = > {
const [ formula , extension ] : string [ ] = line . split ( '=' ) ;
const prefix : string =
extension == 'xdebug' ? 'zend_extension' : 'extension' ;
2022-11-14 16:47:12 +07:00
const ext_name = extension . replace ( /\d+|(pdo|pecl)[_-]/ , '' ) ;
2022-01-29 06:59:58 +07:00
const output : string = fs . existsSync (
2022-11-14 16:47:12 +07:00
` src/scripts/extensions/ ${ ext_name } .sh `
2022-01-29 06:59:58 +07:00
)
2022-11-14 16:47:12 +07:00
? ` add_ ${ ext_name } `
2021-10-09 09:41:39 +07:00
: ` add_brew_extension ${ formula } ${ prefix } ` ;
2022-07-16 02:16:28 +07:00
return [ formula , formula === 'phalcon3' ? '7.3' : '7.4' , output ] ;
2021-10-09 09:41:39 +07:00
} ) ;
it . each ( data ) (
'checking addExtensionOnDarwin for brew extension %s' ,
async ( extension , version , output ) = > {
expect (
await extensions . addExtension ( extension , version , 'darwin' )
) . toContain ( output ) ;
}
) ;
2021-10-08 21:58:41 +07:00
it . each `
extension | version | output
$ { 'xdebug' } | $ { '7.2' } | $ { 'Platform openbsd is not supported' }
` (
'checking addExtension on openbsd for extension $extension on version $version' ,
async ( { extension , version , output } ) = > {
expect (
await extensions . addExtension ( extension , version , 'openbsd' )
) . toContain ( output ) ;
}
) ;
2019-10-08 19:42:54 +07:00
} ) ;