diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2023-06-06 10:46:55 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-11-12 09:40:57 +0000 |
| commit | 6cca632936a2ceb6dec8a47fe4dde1359fe4b39a (patch) | |
| tree | 54ca0101f7cfaddcede231e8beb1419619a7c502 /tests/unit/lib/classes | |
| parent | eaad38435adcfd9f3cba50c6fb8c9abba18b004e (diff) | |
add tests for SimpleORMap::buildSQLQuery(), re #1885tic-1885
Diffstat (limited to 'tests/unit/lib/classes')
| -rw-r--r-- | tests/unit/lib/classes/SimpleOrMapNodbTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/lib/classes/SimpleOrMapNodbTest.php b/tests/unit/lib/classes/SimpleOrMapNodbTest.php index 3ede1aa..b155b39 100644 --- a/tests/unit/lib/classes/SimpleOrMapNodbTest.php +++ b/tests/unit/lib/classes/SimpleOrMapNodbTest.php @@ -351,6 +351,36 @@ class SimpleOrMapNodbTest extends \Codeception\Test\Unit } /** + * @depends testConstruct + * @covers SimpleORMap::buildSQLQuery + */ + public function testQueryBuilder(auth_user_md5 $a) + { + $this->assertEqualsWithoutWhitespace( + 'SELECT 1 FROM `auth_user_md5` WHERE 1', + auth_user_md5::buildSQLQuery('1', '1') + ); + + $this->assertEqualsWithoutWhitespace( + 'SELECT 1 FROM `auth_user_md5` JOIN `foo` USING (`bar`) WHERE 1', + auth_user_md5::buildSQLQuery('JOIN `foo` USING (`bar`) WHERE 1', '1') + ); + } + + public function assertEqualsWithoutWhitespace(string $expected, string $actual, bool $ignore_case = false): void + { + $expected = preg_replace('/\s+/', ' ', $expected); + $actual = preg_replace('/\s+/', ' ', $actual); + + if ($ignore_case) { + $expected = mb_strtolower($expected); + $actual = mb_strtolower($actual); + } + + $this->assertEquals($expected, $actual); + } + + /** * @dataProvider i18nProvider * @covers SimpleORMap::isI18nField * @covers SimpleORMap::i18n_fields |
