Skip to content

Commit 2532743

Browse files
no message
1 parent ad08fc0 commit 2532743

14 files changed

+58
-58
lines changed

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateExtractTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT EXTRACT('DAY' FROM c0_.date1) AS sclr_0 FROM ContainsDates c0_",
23-
"SELECT EXTRACT('MONTH' FROM c0_.date1) AS sclr_0 FROM ContainsDates c0_",
24-
"SELECT EXTRACT('YEAR' FROM c0_.date1) AS sclr_0 FROM ContainsDates c0_",
25-
"SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE EXTRACT('DAY' FROM c0_.date1) = 7",
26-
"SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE EXTRACT('MONTH' FROM c0_.date1) = 12",
22+
'extracts day from date' => "SELECT EXTRACT('DAY' FROM c0_.date1) AS sclr_0 FROM ContainsDates c0_",
23+
'extracts month from date' => "SELECT EXTRACT('MONTH' FROM c0_.date1) AS sclr_0 FROM ContainsDates c0_",
24+
'extracts year from date' => "SELECT EXTRACT('YEAR' FROM c0_.date1) AS sclr_0 FROM ContainsDates c0_",
25+
'filters by extracted day' => "SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE EXTRACT('DAY' FROM c0_.date1) = 7",
26+
'filters by extracted month' => "SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE EXTRACT('MONTH' FROM c0_.date1) = 12",
2727
];
2828
}
2929

3030
protected function getDqlStatements(): array
3131
{
3232
return [
33-
\sprintf("SELECT DATE_EXTRACT('DAY', e.date1) FROM %s e", ContainsDates::class),
34-
\sprintf("SELECT DATE_EXTRACT('MONTH', e.date1) FROM %s e", ContainsDates::class),
35-
\sprintf("SELECT DATE_EXTRACT('YEAR', e.date1) FROM %s e", ContainsDates::class),
36-
\sprintf("SELECT e.date1 FROM %s e WHERE DATE_EXTRACT('DAY', e.date1) = 7", ContainsDates::class),
37-
\sprintf("SELECT e.date1 FROM %s e WHERE DATE_EXTRACT('MONTH', e.date1) = 12", ContainsDates::class),
33+
'extracts day from date' => \sprintf("SELECT DATE_EXTRACT('DAY', e.date1) FROM %s e", ContainsDates::class),
34+
'extracts month from date' => \sprintf("SELECT DATE_EXTRACT('MONTH', e.date1) FROM %s e", ContainsDates::class),
35+
'extracts year from date' => \sprintf("SELECT DATE_EXTRACT('YEAR', e.date1) FROM %s e", ContainsDates::class),
36+
'filters by extracted day' => \sprintf("SELECT e.date1 FROM %s e WHERE DATE_EXTRACT('DAY', e.date1) = 7", ContainsDates::class),
37+
'filters by extracted month' => \sprintf("SELECT e.date1 FROM %s e WHERE DATE_EXTRACT('MONTH', e.date1) = 12", ContainsDates::class),
3838
];
3939
}
4040
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateOverlapsTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE (c0_.date1, c0_.date2) OVERLAPS ('2001-12-21', '2001-12-25') = 0",
23-
"SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE (c0_.date1, c0_.date2) OVERLAPS ('2001-12-21', '2001-12-25') = 1",
24-
"SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE (c0_.date1, COALESCE(c0_.date2, CURRENT_DATE)) OVERLAPS ('2001-12-21', '2001-12-25') = 1",
25-
"SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE (c0_.date1, COALESCE(c0_.date2, CURRENT_DATE)) OVERLAPS ('2001-12-21', '2001-12-25') = 0",
22+
'checks non-overlapping date ranges' => "SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE (c0_.date1, c0_.date2) OVERLAPS ('2001-12-21', '2001-12-25') = 0",
23+
'checks overlapping date ranges' => "SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE (c0_.date1, c0_.date2) OVERLAPS ('2001-12-21', '2001-12-25') = 1",
24+
'checks overlapping with null handling true' => "SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE (c0_.date1, COALESCE(c0_.date2, CURRENT_DATE)) OVERLAPS ('2001-12-21', '2001-12-25') = 1",
25+
'checks overlapping with null handling false' => "SELECT c0_.date1 AS date1_0 FROM ContainsDates c0_ WHERE (c0_.date1, COALESCE(c0_.date2, CURRENT_DATE)) OVERLAPS ('2001-12-21', '2001-12-25') = 0",
2626
];
2727
}
2828

2929
protected function getDqlStatements(): array
3030
{
3131
return [
32-
\sprintf(
32+
'checks non-overlapping date ranges' => \sprintf(
3333
"SELECT e.date1 FROM %s e WHERE DATE_OVERLAPS(e.date1, e.date2, '2001-12-21', '2001-12-25') = 0",
3434
ContainsDates::class
3535
),
36-
\sprintf(
36+
'checks overlapping date ranges' => \sprintf(
3737
"SELECT e.date1 FROM %s e WHERE DATE_OVERLAPS(e.date1, e.date2, '2001-12-21', '2001-12-25') = TRUE",
3838
ContainsDates::class
3939
),
40-
\sprintf(
40+
'checks overlapping with null handling true' => \sprintf(
4141
"SELECT e.date1 FROM %s e WHERE DATE_OVERLAPS(e.date1, COALESCE(e.date2, CURRENT_DATE()), '2001-12-21', '2001-12-25') = 1",
4242
ContainsDates::class
4343
),
44-
\sprintf(
44+
'checks overlapping with null handling false' => \sprintf(
4545
"SELECT e.date1 FROM %s e WHERE DATE_OVERLAPS(e.date1, COALESCE(e.date2, CURRENT_DATE()), '2001-12-21', '2001-12-25') = FALSE",
4646
ContainsDates::class
4747
),

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpMatchTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT regexp_match(c0_.text1, 'pattern', 'i') AS sclr_0 FROM ContainsTexts c0_",
22+
'matches text using regex with flags' => "SELECT regexp_match(c0_.text1, 'pattern', 'i') AS sclr_0 FROM ContainsTexts c0_",
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
\sprintf("SELECT FLAGGED_REGEXP_MATCH(e.text1, 'pattern', 'i') FROM %s e", ContainsTexts::class),
29+
'matches text using regex with flags' => \sprintf("SELECT FLAGGED_REGEXP_MATCH(e.text1, 'pattern', 'i') FROM %s e", ContainsTexts::class),
3030
];
3131
}
3232
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/FlaggedRegexpReplaceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT regexp_replace(c0_.text1, 'pattern', 'replacement', 'g') AS sclr_0 FROM ContainsTexts c0_",
22+
'replaces text using regex with flags' => "SELECT regexp_replace(c0_.text1, 'pattern', 'replacement', 'g') AS sclr_0 FROM ContainsTexts c0_",
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
\sprintf("SELECT FLAGGED_REGEXP_REPLACE(e.text1, 'pattern', 'replacement', 'g') FROM %s e", ContainsTexts::class),
29+
'replaces text using regex with flags' => \sprintf("SELECT FLAGGED_REGEXP_REPLACE(e.text1, 'pattern', 'replacement', 'g') FROM %s e", ContainsTexts::class),
3030
];
3131
}
3232
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/IRegexpTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT (c0_.text1 ~* '.*Thomas.*') AS sclr_0 FROM ContainsTexts c0_",
22+
'case-insensitive regex pattern matching' => "SELECT (c0_.text1 ~* '.*Thomas.*') AS sclr_0 FROM ContainsTexts c0_",
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
\sprintf("SELECT IREGEXP(e.text1, '.*Thomas.*') FROM %s e", ContainsTexts::class),
29+
'case-insensitive regex pattern matching' => \sprintf("SELECT IREGEXP(e.text1, '.*Thomas.*') FROM %s e", ContainsTexts::class),
3030
];
3131
}
3232
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/IsContainedByTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT (c0_.textArray <@ '{681,1185,1878}') AS sclr_0 FROM ContainsArrays c0_",
22+
'checks if left array is contained by right array' => "SELECT (c0_.textArray <@ '{681,1185,1878}') AS sclr_0 FROM ContainsArrays c0_",
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
\sprintf("SELECT IS_CONTAINED_BY(e.textArray, '{681,1185,1878}') FROM %s e", ContainsArrays::class),
29+
'checks if left array is contained by right array' => \sprintf("SELECT IS_CONTAINED_BY(e.textArray, '{681,1185,1878}') FROM %s e", ContainsArrays::class),
3030
];
3131
}
3232
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT json_value(c0_.object1, '$.name') AS sclr_0 FROM ContainsJsons c0_",
23-
"SELECT json_value(c0_.object1, '$.address.city') AS sclr_0 FROM ContainsJsons c0_",
24-
"SELECT json_value(c0_.object1, '$.items[0]') AS sclr_0 FROM ContainsJsons c0_",
22+
'extracts simple property value' => "SELECT json_value(c0_.object1, '$.name') AS sclr_0 FROM ContainsJsons c0_",
23+
'extracts nested property value' => "SELECT json_value(c0_.object1, '$.address.city') AS sclr_0 FROM ContainsJsons c0_",
24+
'extracts array element value' => "SELECT json_value(c0_.object1, '$.items[0]') AS sclr_0 FROM ContainsJsons c0_",
2525
];
2626
}
2727

2828
protected function getDqlStatements(): array
2929
{
3030
return [
31-
\sprintf("SELECT JSON_VALUE(e.object1, '$.name') FROM %s e", ContainsJsons::class),
32-
\sprintf("SELECT JSON_VALUE(e.object1, '$.address.city') FROM %s e", ContainsJsons::class),
33-
\sprintf("SELECT JSON_VALUE(e.object1, '$.items[0]') FROM %s e", ContainsJsons::class),
31+
'extracts simple property value' => \sprintf("SELECT JSON_VALUE(e.object1, '$.name') FROM %s e", ContainsJsons::class),
32+
'extracts nested property value' => \sprintf("SELECT JSON_VALUE(e.object1, '$.address.city') FROM %s e", ContainsJsons::class),
33+
'extracts array element value' => \sprintf("SELECT JSON_VALUE(e.object1, '$.items[0]') FROM %s e", ContainsJsons::class),
3434
];
3535
}
3636
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/NotIRegexpTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT (c0_.text1 !~* '.*Thomas.*') AS sclr_0 FROM ContainsTexts c0_",
22+
'case-insensitive regex pattern non-matching' => "SELECT (c0_.text1 !~* '.*Thomas.*') AS sclr_0 FROM ContainsTexts c0_",
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
\sprintf("SELECT NOT_IREGEXP(e.text1, '.*Thomas.*') FROM %s e", ContainsTexts::class),
29+
'case-insensitive regex pattern non-matching' => \sprintf("SELECT NOT_IREGEXP(e.text1, '.*Thomas.*') FROM %s e", ContainsTexts::class),
3030
];
3131
}
3232
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/OverlapsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT (c0_.textArray && '{681,1185,1878}') AS sclr_0 FROM ContainsArrays c0_",
22+
'checks if arrays have overlapping elements' => "SELECT (c0_.textArray && '{681,1185,1878}') AS sclr_0 FROM ContainsArrays c0_",
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
\sprintf("SELECT OVERLAPS(e.textArray, '{681,1185,1878}') FROM %s e", ContainsArrays::class),
29+
'checks if arrays have overlapping elements' => \sprintf("SELECT OVERLAPS(e.textArray, '{681,1185,1878}') FROM %s e", ContainsArrays::class),
3030
];
3131
}
3232
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/StrConcatTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
"SELECT (c0_.text1 || 'text2') AS sclr_0 FROM ContainsTexts c0_",
22+
'concatenates field with literal string' => "SELECT (c0_.text1 || 'text2') AS sclr_0 FROM ContainsTexts c0_",
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
\sprintf("SELECT STRCONCAT(e.text1, 'text2') FROM %s e", ContainsTexts::class),
29+
'concatenates field with literal string' => \sprintf("SELECT STRCONCAT(e.text1, 'text2') FROM %s e", ContainsTexts::class),
3030
];
3131
}
3232
}

0 commit comments

Comments
 (0)