|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +namespace tests\unit\Magento\FunctionalTestFramework\Console; |
| 7 | + |
| 8 | +use PHPUnit\Framework\TestCase; |
| 9 | +use Magento\FunctionalTestingFramework\Exceptions\FastFailException; |
| 10 | +use Magento\FunctionalTestingFramework\Console\GenerateTestsCommand; |
| 11 | + |
| 12 | +class GenerateTestsCommandTest extends TestCase |
| 13 | +{ |
| 14 | + /** |
| 15 | + * @param mixed $time |
| 16 | + * @param mixed $groups |
| 17 | + * @param mixed $expected |
| 18 | + * @return void |
| 19 | + * @dataProvider configParallelOptions |
| 20 | + */ |
| 21 | + public function testParseConfigParallelOptions($time, $groups, $expected): void |
| 22 | + { |
| 23 | + $command = new GenerateTestsCommand(); |
| 24 | + $class = new \ReflectionClass($command); |
| 25 | + $method = $class->getMethod('parseConfigParallelOptions'); |
| 26 | + $method->setAccessible(true); |
| 27 | + |
| 28 | + if (is_array($expected)) { |
| 29 | + $actual = $method->invokeArgs($command, [$time, $groups]); |
| 30 | + $this->assertEquals($expected, $actual); |
| 31 | + } else { |
| 32 | + $this->expectException(FastFailException::class); |
| 33 | + $this->expectExceptionMessage($expected); |
| 34 | + $method->invokeArgs($command, [$time, $groups]); |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Data provider for testParseConfigParallelOptions() |
| 40 | + * |
| 41 | + * @return array |
| 42 | + */ |
| 43 | + public function configParallelOptions(): array |
| 44 | + { |
| 45 | + return [ |
| 46 | + [null, null, ['parallelByTime', 600000]], /* #0 */ |
| 47 | + ['20', null, ['parallelByTime', 1200000]], /* #1 */ |
| 48 | + [5, null, ['parallelByTime', 300000]], /* #2 */ |
| 49 | + [null, '300', ['parallelByGroup', 300]], /* #3 */ |
| 50 | + [null, 1000, ['parallelByGroup', 1000]], /* #4 */ |
| 51 | + [0.5, null, "'time' option must be an integer and greater than 0"], /* #5 */ |
| 52 | + [0, null, "'time' option must be an integer and greater than 0"], /* #6 */ |
| 53 | + ['0', null, "'time' option must be an integer and greater than 0"], /* #7 */ |
| 54 | + [0.0, null, "'time' option must be an integer and greater than 0"], /* #8 */ |
| 55 | + ['0.0', null, "'time' option must be an integer and greater than 0"], /* #9 */ |
| 56 | + [-10, null, "'time' option must be an integer and greater than 0"], /* #10 */ |
| 57 | + ['-10', null, "'time' option must be an integer and greater than 0"], /* #11 */ |
| 58 | + ['12x', null, "'time' option must be an integer and greater than 0"], /* #12 */ |
| 59 | + [null, 0.5, "'groups' option must be an integer and greater than 0"], /* #13 */ |
| 60 | + [null, 0, "'groups' option must be an integer and greater than 0"], /* #14 */ |
| 61 | + [null, 0.0, "'groups' option must be an integer and greater than 0"], /* #15 */ |
| 62 | + [null, '0', "'groups' option must be an integer and greater than 0"], /* #16 */ |
| 63 | + [null, '0.0', "'groups' option must be an integer and greater than 0"], /* #17 */ |
| 64 | + [null, -10, "'groups' option must be an integer and greater than 0"], /* #18 */ |
| 65 | + [null, '-10', "'groups' option must be an integer and greater than 0"], /* #19 */ |
| 66 | + [null, '12x', "'groups' option must be an integer and greater than 0"], /* #20 */ |
| 67 | + ['20', '300', "'time' and 'groups' options are mutually exclusive. " |
| 68 | + . "Only one can be specified for 'config parallel'" |
| 69 | + ], /* #21 */ |
| 70 | + [20, 300, "'time' and 'groups' options are mutually exclusive. " |
| 71 | + . "Only one can be specified for 'config parallel'" |
| 72 | + ], /* #22 */ |
| 73 | + ['0', 0, "'time' and 'groups' options are mutually exclusive. " |
| 74 | + . "Only one can be specified for 'config parallel'" |
| 75 | + ], /* #23 */ |
| 76 | + [[1], null, "'time' option must be an integer and greater than 0"], /* #24 */ |
| 77 | + [null, [-1], "'groups' option must be an integer and greater than 0"], /* #25 */ |
| 78 | + ]; |
| 79 | + } |
| 80 | +} |
0 commit comments