From b6c1882d594ab2a9a5a85a60dc633fdf05926c23 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Sun, 17 Mar 2024 00:23:54 +0400 Subject: [PATCH] Fixes --- README.md | 35 +++++----- src/Rules/Ruleset.php | 12 ++-- tests/Blueprint/ValidateCsvTest.php | 100 +++++++++++++++------------- tests/Blueprint/ValidatorTest.php | 50 +++++++------- tests/schemas/simple_header.php | 9 ++- 5 files changed, 110 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index 52d2168c..e1ccbfc2 100644 --- a/README.md +++ b/README.md @@ -206,24 +206,27 @@ Schema: ./tests/schemas/demo_invalid.yml Found CSV files: 3 (1/3) Invalid file: ./tests/fixtures/batch/demo-1.csv -+------+------------------+--------------+----------------- demo-1.csv -----------------------------------------------------------+ -| Line | id:Column | Rule | Message | -+------+------------------+--------------+----------------------------------------------------------------------------------------+ -| 1 | 1:City | ag:is_unique | Column has non-unique values. Unique: 1, total: 2 | -| 3 | 2:Float | num_max | The number of the "74605.944" is 74605.944, which is greater than the expected "74605" | -| 3 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", "green", "Blue"] | -+------+------------------+--------------+----------------- demo-1.csv -----------------------------------------------------------+ ++------+------------------+--------------+-------------- demo-1.csv -------------------------------------------------------+ +| Line | id:Column | Rule | Message | ++------+------------------+--------------+---------------------------------------------------------------------------------+ +| 1 | 1:City | ag:is_unique | Column has non-unique values. Unique: 1, total: 2 | +| 3 | 2:Float | num_max | The number of the value "74605.944", which is greater than the expected "74605" | +| 3 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", "green", "Blue"] | ++------+------------------+--------------+-------------- demo-1.csv -------------------------------------------------------+ (2/3) Invalid file: ./tests/fixtures/batch/demo-2.csv -+------+------------+------------+------------------ demo-2.csv ----------------------------------------------------+ -| Line | id:Column | Rule | Message | -+------+------------+------------+----------------------------------------------------------------------------------+ -| 2 | 0:Name | length_min | The length of the "Carl" is 4, which is less than the expected "5" | -| 7 | 0:Name | length_min | The length of the "Lois" is 4, which is less than the expected "5" | -| 2 | 3:Birthday | date_min | Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00" | -| 4 | 3:Birthday | date_min | Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00" | -| 5 | 3:Birthday | date_max | Value "2010-07-20" is more than the maximum date "2009-01-01T00:00:00.000+00:00" | -+------+------------+------------+------------------ demo-2.csv ----------------------------------------------------+ ++------+------------+------------+-------------------------- demo-2.csv ------------------------------------------------------------+ +| Line | id:Column | Rule | Message | ++------+------------+------------+--------------------------------------------------------------------------------------------------+ +| 2 | 0:Name | length_min | The length of the value "Carl" is 4, which is less than the expected "5" | +| 7 | 0:Name | length_min | The length of the value "Lois" is 4, which is less than the expected "5" | +| 2 | 3:Birthday | date_min | The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than | +| | | | the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)" | +| 4 | 3:Birthday | date_min | The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than | +| | | | the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)" | +| 5 | 3:Birthday | date_max | The date of the value "2010-07-20" is parsed as "2010-07-20 00:00:00 +00:00", which is greater | +| | | | than the expected "2009-01-01 00:00:00 +00:00 (2009-01-01)" | ++------+------------+------------+-------------------------- demo-2.csv ------------------------------------------------------------+ (3/3) Invalid file: ./tests/fixtures/batch/sub/demo-3.csv +------+-----------+------------------+---------------------- demo-3.csv ------------------------------------------------------------+ diff --git a/src/Rules/Ruleset.php b/src/Rules/Ruleset.php index 24e8e8eb..81b3c57e 100644 --- a/src/Rules/Ruleset.php +++ b/src/Rules/Ruleset.php @@ -51,8 +51,8 @@ public function ruleDiscovery( string $origRuleName, null|array|bool|float|int|string $options = null, ): AbstarctRule { - $postfix = AbstractCombo::parseMode($origRuleName); - $noCombo = \preg_replace("/(_{$postfix})\$/", '', $origRuleName); + $mode = AbstractCombo::parseMode($origRuleName); + $noCombo = \preg_replace("/(_{$mode})\$/", '', $origRuleName); $origRuleClass = Utils::kebabToCamelCase($origRuleName); $comboRuleClass = Utils::kebabToCamelCase("combo_{$noCombo}"); @@ -61,7 +61,7 @@ public function ruleDiscovery( foreach ([$origRuleClass, $comboRuleClass] as $ruleClass) { $posibleClassName = __NAMESPACE__ . "\\{$group}\\{$ruleClass}"; - $rule = $this->createRuleClassAttempt($posibleClassName, $origRuleName, $options); + $rule = $this->createRuleClassAttempt($posibleClassName, $options, $mode); if ($rule !== null) { return $rule; } @@ -77,12 +77,12 @@ public function ruleDiscovery( */ private function createRuleClassAttempt( string $posibleClassName, - string $ruleName, - null|array|bool|float|int|string $options = null, + null|array|bool|float|int|string $options, + string $mode, ): ?AbstarctRule { if (\class_exists($posibleClassName)) { // @phpstan-ignore-next-line - return new $posibleClassName($this->columnNameId, $options, $ruleName); + return new $posibleClassName($this->columnNameId, $options, $mode); } return null; diff --git a/tests/Blueprint/ValidateCsvTest.php b/tests/Blueprint/ValidateCsvTest.php index 731eaf67..ec15d390 100644 --- a/tests/Blueprint/ValidateCsvTest.php +++ b/tests/Blueprint/ValidateCsvTest.php @@ -64,19 +64,22 @@ public function testValidateOneFileNegativeTable(): void Found CSV files: 1 (1/1) Invalid file: ./tests/fixtures/demo.csv - +------+------------------+------------------+---------------- demo.csv --------------------------------------------------------------+ - | Line | id:Column | Rule | Message | - +------+------------------+------------------+----------------------------------------------------------------------------------------+ - | 1 | | filename_pattern | Filename "./tests/fixtures/demo.csv" does not match pattern: "/demo-[12].csv$/i" | - | 6 | 0:Name | length_min | The length of the "Carl" is 4, which is less than the expected "5" | - | 11 | 0:Name | length_min | The length of the "Lois" is 4, which is less than the expected "5" | - | 1 | 1:City | ag:is_unique | Column has non-unique values. Unique: 9, total: 10 | - | 5 | 2:Float | num_max | The number of the "74605.944" is 74605.944, which is greater than the expected "74605" | - | 6 | 3:Birthday | date_min | Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00" | - | 8 | 3:Birthday | date_min | Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00" | - | 9 | 3:Birthday | date_max | Value "2010-07-20" is more than the maximum date "2009-01-01T00:00:00.000+00:00" | - | 5 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", "green", "Blue"] | - +------+------------------+------------------+---------------- demo.csv --------------------------------------------------------------+ + +------+------------------+------------------+--------------------- demo.csv -------------------------------------------------------------------+ + | Line | id:Column | Rule | Message | + +------+------------------+------------------+--------------------------------------------------------------------------------------------------+ + | 1 | | filename_pattern | Filename "./tests/fixtures/demo.csv" does not match pattern: "/demo-[12].csv$/i" | + | 6 | 0:Name | length_min | The length of the value "Carl" is 4, which is less than the expected "5" | + | 11 | 0:Name | length_min | The length of the value "Lois" is 4, which is less than the expected "5" | + | 1 | 1:City | ag:is_unique | Column has non-unique values. Unique: 9, total: 10 | + | 5 | 2:Float | num_max | The number of the value "74605.944", which is greater than the expected "74605" | + | 6 | 3:Birthday | date_min | The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than | + | | | | the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)" | + | 8 | 3:Birthday | date_min | The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than | + | | | | the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)" | + | 9 | 3:Birthday | date_max | The date of the value "2010-07-20" is parsed as "2010-07-20 00:00:00 +00:00", which is greater | + | | | | than the expected "2009-01-01 00:00:00 +00:00 (2009-01-01)" | + | 5 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", "green", "Blue"] | + +------+------------------+------------------+--------------------- demo.csv -------------------------------------------------------------------+ Found 9 issues in CSV file. @@ -103,24 +106,27 @@ public function testValidateManyFileNegativeTable(): void Found CSV files: 3 (1/3) Invalid file: ./tests/fixtures/batch/demo-1.csv - +------+------------------+--------------+----------------- demo-1.csv -----------------------------------------------------------+ - | Line | id:Column | Rule | Message | - +------+------------------+--------------+----------------------------------------------------------------------------------------+ - | 1 | 1:City | ag:is_unique | Column has non-unique values. Unique: 1, total: 2 | - | 3 | 2:Float | num_max | The number of the "74605.944" is 74605.944, which is greater than the expected "74605" | - | 3 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", "green", "Blue"] | - +------+------------------+--------------+----------------- demo-1.csv -----------------------------------------------------------+ + +------+------------------+--------------+-------------- demo-1.csv -------------------------------------------------------+ + | Line | id:Column | Rule | Message | + +------+------------------+--------------+---------------------------------------------------------------------------------+ + | 1 | 1:City | ag:is_unique | Column has non-unique values. Unique: 1, total: 2 | + | 3 | 2:Float | num_max | The number of the value "74605.944", which is greater than the expected "74605" | + | 3 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", "green", "Blue"] | + +------+------------------+--------------+-------------- demo-1.csv -------------------------------------------------------+ (2/3) Invalid file: ./tests/fixtures/batch/demo-2.csv - +------+------------+------------+------------------ demo-2.csv ----------------------------------------------------+ - | Line | id:Column | Rule | Message | - +------+------------+------------+----------------------------------------------------------------------------------+ - | 2 | 0:Name | length_min | The length of the "Carl" is 4, which is less than the expected "5" | - | 7 | 0:Name | length_min | The length of the "Lois" is 4, which is less than the expected "5" | - | 2 | 3:Birthday | date_min | Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00" | - | 4 | 3:Birthday | date_min | Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00" | - | 5 | 3:Birthday | date_max | Value "2010-07-20" is more than the maximum date "2009-01-01T00:00:00.000+00:00" | - +------+------------+------------+------------------ demo-2.csv ----------------------------------------------------+ + +------+------------+------------+-------------------------- demo-2.csv ------------------------------------------------------------+ + | Line | id:Column | Rule | Message | + +------+------------+------------+--------------------------------------------------------------------------------------------------+ + | 2 | 0:Name | length_min | The length of the value "Carl" is 4, which is less than the expected "5" | + | 7 | 0:Name | length_min | The length of the value "Lois" is 4, which is less than the expected "5" | + | 2 | 3:Birthday | date_min | The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than | + | | | | the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)" | + | 4 | 3:Birthday | date_min | The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than | + | | | | the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)" | + | 5 | 3:Birthday | date_max | The date of the value "2010-07-20" is parsed as "2010-07-20 00:00:00 +00:00", which is greater | + | | | | than the expected "2009-01-01 00:00:00 +00:00 (2009-01-01)" | + +------+------------+------------+-------------------------- demo-2.csv ------------------------------------------------------------+ (3/3) Invalid file: ./tests/fixtures/batch/sub/demo-3.csv +------+-----------+------------------+---------------------- demo-3.csv ------------------------------------------------------------+ @@ -154,13 +160,13 @@ public function testValidateOneFileNegativeText(): void (1/1) Invalid file: ./tests/fixtures/demo.csv "filename_pattern" at line 1, column "". Filename "./tests/fixtures/demo.csv" does not match pattern: "/demo-[12].csv$/i". - "length_min" at line 6, column "0:Name". The length of the "Carl" is 4, which is less than the expected "5". - "length_min" at line 11, column "0:Name". The length of the "Lois" is 4, which is less than the expected "5". + "length_min" at line 6, column "0:Name". The length of the value "Carl" is 4, which is less than the expected "5". + "length_min" at line 11, column "0:Name". The length of the value "Lois" is 4, which is less than the expected "5". "ag:is_unique" at line 1, column "1:City". Column has non-unique values. Unique: 9, total: 10. - "num_max" at line 5, column "2:Float". The number of the "74605.944" is 74605.944, which is greater than the expected "74605". - "date_min" at line 6, column "3:Birthday". Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00". - "date_min" at line 8, column "3:Birthday". Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00". - "date_max" at line 9, column "3:Birthday". Value "2010-07-20" is more than the maximum date "2009-01-01T00:00:00.000+00:00". + "num_max" at line 5, column "2:Float". The number of the value "74605.944", which is greater than the expected "74605". + "date_min" at line 6, column "3:Birthday". The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)". + "date_min" at line 8, column "3:Birthday". The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)". + "date_max" at line 9, column "3:Birthday". The date of the value "2010-07-20" is parsed as "2010-07-20 00:00:00 +00:00", which is greater than the expected "2009-01-01 00:00:00 +00:00 (2009-01-01)". "allow_values" at line 5, column "4:Favorite color". Value "blue" is not allowed. Allowed values: ["red", "green", "Blue"]. @@ -243,15 +249,15 @@ public function testValidateManyFilesNegativeTextQuick(): void (1/3) Invalid file: ./tests/fixtures/batch/demo-1.csv "ag:is_unique" at line 1, column "1:City". Column has non-unique values. Unique: 1, total: 2. - "num_max" at line 3, column "2:Float". The number of the "74605.944" is 74605.944, which is greater than the expected "74605". + "num_max" at line 3, column "2:Float". The number of the value "74605.944", which is greater than the expected "74605". "allow_values" at line 3, column "4:Favorite color". Value "blue" is not allowed. Allowed values: ["red", "green", "Blue"]. (2/3) Invalid file: ./tests/fixtures/batch/demo-2.csv - "length_min" at line 2, column "0:Name". The length of the "Carl" is 4, which is less than the expected "5". - "length_min" at line 7, column "0:Name". The length of the "Lois" is 4, which is less than the expected "5". - "date_min" at line 2, column "3:Birthday". Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00". - "date_min" at line 4, column "3:Birthday". Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00". - "date_max" at line 5, column "3:Birthday". Value "2010-07-20" is more than the maximum date "2009-01-01T00:00:00.000+00:00". + "length_min" at line 2, column "0:Name". The length of the value "Carl" is 4, which is less than the expected "5". + "length_min" at line 7, column "0:Name". The length of the value "Lois" is 4, which is less than the expected "5". + "date_min" at line 2, column "3:Birthday". The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)". + "date_min" at line 4, column "3:Birthday". The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)". + "date_max" at line 5, column "3:Birthday". The date of the value "2010-07-20" is parsed as "2010-07-20 00:00:00 +00:00", which is greater than the expected "2009-01-01 00:00:00 +00:00 (2009-01-01)". (3/3) Invalid file: ./tests/fixtures/batch/sub/demo-3.csv "filename_pattern" at line 1, column "". Filename "./tests/fixtures/batch/sub/demo-3.csv" does not match pattern: "/demo-[12].csv$/i". @@ -292,7 +298,7 @@ public function testCreateValidateNegativeTeamcity(): void ##teamcity[testFinished name='ag:is_unique at column 1:City' flowId='42'] ##teamcity[testStarted name='num_max at column 2:Float' locationHint='php_qn://./tests/fixtures/batch/demo-1.csv' flowId='42'] - "num_max" at line 3, column "2:Float". The number of the "74605.944" is 74605.944, which is greater than the expected "74605". + "num_max" at line 3, column "2:Float". The number of the value "74605.944", which is greater than the expected "74605". ##teamcity[testFinished name='num_max at column 2:Float' flowId='42'] ##teamcity[testStarted name='allow_values at column 4:Favorite color' locationHint='php_qn://./tests/fixtures/batch/demo-1.csv' flowId='42'] @@ -308,23 +314,23 @@ public function testCreateValidateNegativeTeamcity(): void ##teamcity[testSuiteStarted name='demo-2.csv' flowId='42'] ##teamcity[testStarted name='length_min at column 0:Name' locationHint='php_qn://./tests/fixtures/batch/demo-2.csv' flowId='42'] - "length_min" at line 2, column "0:Name". The length of the "Carl" is 4, which is less than the expected "5". + "length_min" at line 2, column "0:Name". The length of the value "Carl" is 4, which is less than the expected "5". ##teamcity[testFinished name='length_min at column 0:Name' flowId='42'] ##teamcity[testStarted name='length_min at column 0:Name' locationHint='php_qn://./tests/fixtures/batch/demo-2.csv' flowId='42'] - "length_min" at line 7, column "0:Name". The length of the "Lois" is 4, which is less than the expected "5". + "length_min" at line 7, column "0:Name". The length of the value "Lois" is 4, which is less than the expected "5". ##teamcity[testFinished name='length_min at column 0:Name' flowId='42'] ##teamcity[testStarted name='date_min at column 3:Birthday' locationHint='php_qn://./tests/fixtures/batch/demo-2.csv' flowId='42'] - "date_min" at line 2, column "3:Birthday". Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00". + "date_min" at line 2, column "3:Birthday". The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)". ##teamcity[testFinished name='date_min at column 3:Birthday' flowId='42'] ##teamcity[testStarted name='date_min at column 3:Birthday' locationHint='php_qn://./tests/fixtures/batch/demo-2.csv' flowId='42'] - "date_min" at line 4, column "3:Birthday". Value "1955-05-14" is less than the minimum date "1955-05-15T00:00:00.000+00:00". + "date_min" at line 4, column "3:Birthday". The date of the value "1955-05-14" is parsed as "1955-05-14 00:00:00 +00:00", which is less than the expected "1955-05-15 00:00:00 +00:00 (1955-05-15)". ##teamcity[testFinished name='date_min at column 3:Birthday' flowId='42'] ##teamcity[testStarted name='date_max at column 3:Birthday' locationHint='php_qn://./tests/fixtures/batch/demo-2.csv' flowId='42'] - "date_max" at line 5, column "3:Birthday". Value "2010-07-20" is more than the maximum date "2009-01-01T00:00:00.000+00:00". + "date_max" at line 5, column "3:Birthday". The date of the value "2010-07-20" is parsed as "2010-07-20 00:00:00 +00:00", which is greater than the expected "2009-01-01 00:00:00 +00:00 (2009-01-01)". ##teamcity[testFinished name='date_max at column 3:Birthday' flowId='42'] ##teamcity[testSuiteFinished name='demo-2.csv' flowId='42'] diff --git a/tests/Blueprint/ValidatorTest.php b/tests/Blueprint/ValidatorTest.php index 975c3ae6..488181a5 100644 --- a/tests/Blueprint/ValidatorTest.php +++ b/tests/Blueprint/ValidatorTest.php @@ -71,7 +71,7 @@ public function testSchemaAsPhpFile(): void $csv = new CsvFile(self::CSV_SIMPLE_HEADER, self::SCHEMA_SIMPLE_HEADER_PHP); isSame( '"num_min" at line 2, column "0:seq". ' . - 'The number of the "1" is 1, which is less than the expected "2".' . "\n", + 'The number of the value "1", which is less than the expected "2".' . "\n", \strip_tags((string)$csv->validate()), ); } @@ -81,7 +81,7 @@ public function testSchemaAsJsonFile(): void $csv = new CsvFile(self::CSV_SIMPLE_HEADER, self::SCHEMA_SIMPLE_HEADER_JSON); isSame( '"num_min" at line 2, column "0:seq". ' . - 'The number of the "1" is 1, which is less than the expected "2".' . "\n", + 'The number of the value "1", which is less than the expected "2".' . "\n", \strip_tags((string)$csv->validate()), ); } @@ -151,14 +151,14 @@ public function testRenderText(): void $csv = new CsvFile(self::CSV_SIMPLE_HEADER, $this->getRule('seq', 'num_min', 3)); isSame( '"num_min" at line 2, column "0:seq". ' . - 'The number of the "1" is 1, which is less than the expected "3".' . "\n", + 'The number of the value "1", which is less than the expected "3".' . "\n", \strip_tags($csv->validate(true)->render(ErrorSuite::REPORT_TEXT)), ); isSame( <<<'TEXT' - "num_min" at line 2, column "0:seq". The number of the "1" is 1, which is less than the expected "3". - "num_min" at line 3, column "0:seq". The number of the "2" is 2, which is less than the expected "3". + "num_min" at line 2, column "0:seq". The number of the value "1", which is less than the expected "3". + "num_min" at line 3, column "0:seq". The number of the value "2", which is less than the expected "3". TEXT, \strip_tags($csv->validate()->render(ErrorSuite::REPORT_TEXT)), @@ -170,11 +170,11 @@ public function testRenderTable(): void $csv = new CsvFile(self::CSV_SIMPLE_HEADER, $this->getRule('seq', 'num_min', 3)); isSame( <<<'TABLE' - +------+-----------+---------+-------- simple_header.csv --------------------------------------+ - | Line | id:Column | Rule | Message | - +------+-----------+---------+-----------------------------------------------------------------+ - | 2 | 0:seq | num_min | The number of the "1" is 1, which is less than the expected "3" | - +------+-----------+---------+-------- simple_header.csv --------------------------------------+ + +------+-----------+---------+--------- simple_header.csv --------------------------------------+ + | Line | id:Column | Rule | Message | + +------+-----------+---------+------------------------------------------------------------------+ + | 2 | 0:seq | num_min | The number of the value "1", which is less than the expected "3" | + +------+-----------+---------+--------- simple_header.csv --------------------------------------+ TABLE, $csv->validate(true)->render(ErrorSuite::RENDER_TABLE), @@ -182,12 +182,12 @@ public function testRenderTable(): void isSame( <<<'TABLE' - +------+-----------+---------+-------- simple_header.csv --------------------------------------+ - | Line | id:Column | Rule | Message | - +------+-----------+---------+-----------------------------------------------------------------+ - | 2 | 0:seq | num_min | The number of the "1" is 1, which is less than the expected "3" | - | 3 | 0:seq | num_min | The number of the "2" is 2, which is less than the expected "3" | - +------+-----------+---------+-------- simple_header.csv --------------------------------------+ + +------+-----------+---------+--------- simple_header.csv --------------------------------------+ + | Line | id:Column | Rule | Message | + +------+-----------+---------+------------------------------------------------------------------+ + | 2 | 0:seq | num_min | The number of the value "1", which is less than the expected "3" | + | 3 | 0:seq | num_min | The number of the value "2", which is less than the expected "3" | + +------+-----------+---------+--------- simple_header.csv --------------------------------------+ TABLE, $csv->validate()->render(ErrorSuite::RENDER_TABLE), @@ -203,15 +203,15 @@ public function testRenderTeamCity(): void $expected = <<<'TEAMCITY' ##teamcity[testCount count='2' flowId='42'] - + ##teamcity[testSuiteStarted name='simple_header.csv' flowId='42'] ##teamcity[testStarted name='num_min at column 0:seq' locationHint='php_qn://./tests/fixtures/simple_header.csv' flowId='42'] - "num_min" at line 2, column "0:seq". The number of the "1" is 1, which is less than the expected "3". + "num_min" at line 2, column "0:seq". The number of the value "1", which is less than the expected "3". ##teamcity[testFinished name='num_min at column 0:seq' flowId='42'] ##teamcity[testStarted name='num_min at column 0:seq' locationHint='php_qn://./tests/fixtures/simple_header.csv' flowId='42'] - "num_min" at line 3, column "0:seq". The number of the "2" is 2, which is less than the expected "3". + "num_min" at line 3, column "0:seq". The number of the value "2", which is less than the expected "3". ##teamcity[testFinished name='num_min at column 0:seq' flowId='42'] ##teamcity[testSuiteFinished name='simple_header.csv' flowId='42'] @@ -227,9 +227,9 @@ public function testRenderGithub(): void $csv = new CsvFile($path, $this->getRule('seq', 'num_min', 3)); isSame( <<<'GITHUB' - ::error file=./tests/fixtures/simple_header.csv,line=2::num_min at column 0:seq%0A"num_min" at line 2, column "0:seq". The number of the "1" is 1, which is less than the expected "3". + ::error file=./tests/fixtures/simple_header.csv,line=2::num_min at column 0:seq%0A"num_min" at line 2, column "0:seq". The number of the value "1", which is less than the expected "3". - ::error file=./tests/fixtures/simple_header.csv,line=3::num_min at column 0:seq%0A"num_min" at line 3, column "0:seq". The number of the "2" is 2, which is less than the expected "3". + ::error file=./tests/fixtures/simple_header.csv,line=3::num_min at column 0:seq%0A"num_min" at line 3, column "0:seq". The number of the value "2", which is less than the expected "3". GITHUB, $csv->validate()->render(ErrorSuite::REPORT_GITHUB), @@ -259,13 +259,13 @@ public function testRenderGitlab(): void [ [ 'description' => "num_min at column 0:seq\n\"num_min\" at line 2, column \"0:seq\". " . - 'The number of the "1" is 1, which is less than the expected "3".', + 'The number of the value "1", which is less than the expected "3".', 'severity' => 'major', 'location' => ['path' => $path, 'lines' => ['begin' => 2]], ], [ 'description' => "num_min at column 0:seq\n\"num_min\" at line 3, column \"0:seq\". " . - 'The number of the "2" is 2, which is less than the expected "3".', + 'The number of the value "2", which is less than the expected "3".', 'severity' => 'major', 'location' => ['path' => $path, 'lines' => ['begin' => 3]], ], @@ -284,10 +284,10 @@ public function testRenderJUnit(): void - "num_min" at line 2, column "0:seq". The number of the "1" is 1, which is less than the expected "3". + "num_min" at line 2, column "0:seq". The number of the value "1", which is less than the expected "3". - "num_min" at line 3, column "0:seq". The number of the "2" is 2, which is less than the expected "3". + "num_min" at line 3, column "0:seq". The number of the value "2", which is less than the expected "3". diff --git a/tests/schemas/simple_header.php b/tests/schemas/simple_header.php index d025aa31..1280bb24 100644 --- a/tests/schemas/simple_header.php +++ b/tests/schemas/simple_header.php @@ -18,11 +18,16 @@ 'columns' => [ [ 'name' => 'seq', - 'rules' => ['not_empty' => true, 'num_min' => 2], + 'rules' => [ + 'not_empty' => true, + 'num_min' => 2, + ], ], [ 'name' => 'bool', - 'rules' => ['not_empty' => true], + 'rules' => [ + 'not_empty' => true, + ], ], ], ];