2019-12-27 08:26:49 +07:00
|
|
|
import * as tools from '../src/tools';
|
|
|
|
|
|
|
|
describe('Tools tests', () => {
|
|
|
|
it('checking getToolCommand', async () => {
|
|
|
|
expect(await tools.getToolCommand('linux')).toBe('add_tool ');
|
|
|
|
expect(await tools.getToolCommand('darwin')).toBe('add_tool ');
|
|
|
|
expect(await tools.getToolCommand('win32')).toBe('Add-Tool ');
|
|
|
|
expect(await tools.getToolCommand('fedora')).toContain(
|
|
|
|
'Platform fedora is not supported'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('checking getPECLCommand', async () => {
|
|
|
|
expect(await tools.getPECLCommand('linux')).toBe('add_pecl ');
|
|
|
|
expect(await tools.getPECLCommand('darwin')).toBe('add_pecl ');
|
|
|
|
expect(await tools.getPECLCommand('win32')).toBe('Add-PECL ');
|
|
|
|
expect(await tools.getPECLCommand('fedora')).toContain(
|
|
|
|
'Platform fedora is not supported'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2019-12-31 05:56:18 +07:00
|
|
|
it('checking linkTool', async () => {
|
|
|
|
expect(await tools.linkTool('tool', 'linux')).toContain(
|
|
|
|
'sudo ln -s "$(composer -q global config home)"/vendor/bin/tool /usr/local/bin/tool'
|
|
|
|
);
|
|
|
|
expect(await tools.linkTool('tool', 'darwin')).toContain(
|
|
|
|
'sudo ln -s "$(composer -q global config home)"/vendor/bin/tool /usr/local/bin/tool'
|
|
|
|
);
|
|
|
|
expect(await tools.linkTool('tool', 'win32')).toContain(
|
|
|
|
'$composer_dir = composer -q global config home | % {$_ -replace "/", "\\"}'
|
|
|
|
);
|
|
|
|
expect(await tools.linkTool('tool', 'win32')).toContain(
|
|
|
|
'Add-Content -Path $PsHome\\profile.ps1 -Value "New-Alias tool $composer_dir\\vendor\\bin\\tool.bat"'
|
|
|
|
);
|
|
|
|
expect(await tools.linkTool('tool', 'fedora')).toContain(
|
|
|
|
'Platform fedora is not supported'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2019-12-27 08:26:49 +07:00
|
|
|
it('checking addTools', async () => {
|
|
|
|
let script: string = await tools.addTools(
|
2019-12-28 02:12:00 +07:00
|
|
|
'php-cs-fixer, phpstan, phpunit, pecl, phinx',
|
2019-12-27 08:26:49 +07:00
|
|
|
'linux'
|
|
|
|
);
|
|
|
|
expect(script).toContain(
|
2019-12-28 02:12:00 +07:00
|
|
|
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
2019-12-27 08:26:49 +07:00
|
|
|
);
|
|
|
|
expect(script).toContain(
|
2019-12-28 02:12:00 +07:00
|
|
|
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer'
|
|
|
|
);
|
|
|
|
expect(script).toContain(
|
|
|
|
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
|
|
|
|
);
|
|
|
|
expect(script).toContain(
|
|
|
|
'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
|
2019-12-27 08:26:49 +07:00
|
|
|
);
|
|
|
|
expect(script).toContain('add_pecl');
|
2019-12-28 02:12:00 +07:00
|
|
|
expect(script).toContain('composer global require robmorgan/phinx');
|
2019-12-31 05:56:18 +07:00
|
|
|
expect(script).toContain(
|
|
|
|
'sudo ln -s "$(composer -q global config home)"/vendor/bin/phinx /usr/local/bin/phinx'
|
|
|
|
);
|
2019-12-27 08:26:49 +07:00
|
|
|
|
2019-12-28 02:12:00 +07:00
|
|
|
script = await tools.addTools(
|
2019-12-31 05:56:18 +07:00
|
|
|
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx',
|
2019-12-28 02:12:00 +07:00
|
|
|
'darwin'
|
|
|
|
);
|
|
|
|
expect(script).toContain(
|
|
|
|
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
|
|
|
);
|
|
|
|
expect(script).toContain(
|
|
|
|
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
|
|
|
|
);
|
2019-12-27 08:26:49 +07:00
|
|
|
expect(script).toContain(
|
2019-12-28 02:12:00 +07:00
|
|
|
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf'
|
2019-12-27 08:26:49 +07:00
|
|
|
);
|
|
|
|
expect(script).toContain(
|
2019-12-28 02:12:00 +07:00
|
|
|
'add_tool https://github.com/sebastianbergmann/phpcpd/releases/latest/download/phpcpd.phar phpcpd'
|
2019-12-27 08:26:49 +07:00
|
|
|
);
|
|
|
|
expect(script).toContain(
|
2019-12-28 02:12:00 +07:00
|
|
|
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
|
2019-12-27 08:26:49 +07:00
|
|
|
);
|
|
|
|
expect(script).toContain(
|
2019-12-28 02:12:00 +07:00
|
|
|
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
|
2019-12-27 08:26:49 +07:00
|
|
|
);
|
2019-12-31 05:56:18 +07:00
|
|
|
expect(script).toContain('composer global require robmorgan/phinx');
|
|
|
|
expect(script).toContain(
|
|
|
|
'sudo ln -s "$(composer -q global config home)"/vendor/bin/phinx /usr/local/bin/phinx'
|
|
|
|
);
|
2019-12-27 08:26:49 +07:00
|
|
|
|
|
|
|
script = await tools.addTools(
|
2019-12-31 05:56:18 +07:00
|
|
|
'codeception, deployer, prestissimo, phpmd, phinx, does_not_exit',
|
2019-12-27 08:26:49 +07:00
|
|
|
'win32'
|
|
|
|
);
|
2019-12-28 02:12:00 +07:00
|
|
|
expect(script).toContain(
|
|
|
|
'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
|
|
|
);
|
|
|
|
expect(script).toContain(
|
|
|
|
'Add-Tool https://deployer.org/deployer.phar deployer'
|
|
|
|
);
|
2019-12-27 08:26:49 +07:00
|
|
|
expect(script).toContain('composer global require hirak/prestissimo');
|
2019-12-31 05:56:18 +07:00
|
|
|
expect(script).toContain('composer global require robmorgan/phinx');
|
|
|
|
expect(script).toContain(
|
|
|
|
'$composer_dir = composer -q global config home | % {$_ -replace "/", "\\"}'
|
|
|
|
);
|
|
|
|
expect(script).toContain(
|
|
|
|
'Add-Content -Path $PsHome\\profile.ps1 -Value "New-Alias phinx $composer_dir\\vendor\\bin\\phinx.bat"'
|
|
|
|
);
|
2019-12-27 08:26:49 +07:00
|
|
|
expect(script).toContain('Tool does_not_exit is not supported');
|
|
|
|
});
|
|
|
|
});
|