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' }
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' }
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' }
$ { 'pecl_http' } | $ { '7.3' } | $ { 'add_http' }
$ { 'phalcon3' } | $ { '7.3' } | $ { 'add_phalcon phalcon3' }
$ { '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' }
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' }
$ { 'sqlite' } | $ { '7.2' } | $ { 'add_extension sqlite3' }
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-01-02 18:51:14 +07:00
const output : string = fs . existsSync ( ` src/scripts/extensions/ ${ extension } .sh ` )
2021-10-09 09:41:39 +07:00
? ` add_ ${ extension } `
: ` add_brew_extension ${ formula } ${ prefix } ` ;
return [ formula , '7.3' , output ] ;
} ) ;
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
} ) ;