|string, argumentCount: string, passCellReference?: bool, passByReference?: array, custom?: bool}> $phpSpreadsheetFunctions */ #[DataProvider('providerGenerateFunctionListByName')] public function testGenerateFunctionListByName(array $phpSpreadsheetFunctions, string $expected): void { self::assertEquals($expected, DocumentGenerator::generateFunctionListByName($phpSpreadsheetFunctions)); self::$succeededByName = true; } /** @param array|string, argumentCount: string, passCellReference?: bool, passByReference?: array, custom?: bool}> $phpSpreadsheetFunctions */ #[DataProvider('providerGenerateFunctionListByCategory')] public function testGenerateFunctionListByCategory(array $phpSpreadsheetFunctions, string $expected): void { self::assertEquals($expected, DocumentGenerator::generateFunctionListByCategory($phpSpreadsheetFunctions)); self::$succeededByCategory = true; } public static function providerGenerateFunctionListByName(): array { return [ [ [ 'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs', 'argumentCount' => '1'], 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Operations::class, 'logicalAnd'], 'argumentCount' => '2'], 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '3'], ], <<<'EXPECTED' # Function list by name A more compact list can be found [here](./function-list-by-name-compact.md) ## A Excel Function | Category | PhpSpreadsheet Function -------------------------|--------------------------------|-------------------------------------- ABS | CATEGORY_MATH_AND_TRIG | abs AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations::logicalAnd ## I Excel Function | Category | PhpSpreadsheet Function -------------------------|--------------------------------|-------------------------------------- IFS | CATEGORY_LOGICAL | **Not yet Implemented** EXPECTED ], ]; } public static function providerGenerateFunctionListByCategory(): array { return [ [ [ 'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs', 'argumentCount' => '1'], 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Operations::class, 'logicalAnd'], 'argumentCount' => '2'], 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '3'], ], <<<'EXPECTED' # Function list by category ## CATEGORY_CUBE Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_DATABASE Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_DATE_AND_TIME Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_ENGINEERING Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_FINANCIAL Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_INFORMATION Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_LOGICAL Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations::logicalAnd IFS | **Not yet Implemented** ## CATEGORY_LOOKUP_AND_REFERENCE Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_MATH_AND_TRIG Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ABS | abs ## CATEGORY_STATISTICAL Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_TEXT_AND_DATA Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_WEB Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_UNCATEGORISED Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ## CATEGORY_MICROSOFT_INTERNAL Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- EXPECTED ], ]; } public function testGenerateFunctionBadArray(): void { $this->expectException(UnexpectedValueException::class); $phpSpreadsheetFunctions = [ 'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 1], ]; DocumentGenerator::generateFunctionListByName( $phpSpreadsheetFunctions //* @phpstan-ignore argument.type (deliberate run-time test) ); } public function testGenerateDocuments(): void { if (!self::$succeededByName || !self::$succeededByCategory) { self::markTestSkipped('Not run because prior test failed'); } $directory = 'docs/references/'; $phpSpreadsheetFunctions = Calculation::getFunctions(); ksort($phpSpreadsheetFunctions); self::assertNotFalse(file_put_contents( $directory . 'function-list-by-category.md', DocumentGenerator::generateFunctionListByCategory( $phpSpreadsheetFunctions ) )); self::assertNotFalse(file_put_contents( $directory . 'function-list-by-name.md', DocumentGenerator::generateFunctionListByName( $phpSpreadsheetFunctions ) )); self::assertNotFalse(file_put_contents( $directory . 'function-list-by-name-compact.md', DocumentGenerator::generateFunctionListByName( $phpSpreadsheetFunctions, true ) )); } }