From 1a688e5ec4c4c96f7017b59bb2dbfac78c7c81d1 Mon Sep 17 00:00:00 2001 From: Zoltan Flamis Date: Mon, 15 Mar 2021 15:34:03 +1300 Subject: modify SegmentQueryDecorator so extra comment information can be saved (#17337) * modify SegmentQueryDecorator so extra comment information can be saved * Update LogAggregator.php * fix tests --- .../tests/Integration/SegmentQueryDecoratorTest.php | 15 ++++++++------- .../tests/Unit/SegmentQueryDecoratorTest.php | 6 ++++-- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'plugins/SegmentEditor/tests') diff --git a/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php b/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php index 7cf0c46de3..7cc9158cd0 100644 --- a/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php +++ b/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php @@ -72,22 +72,23 @@ class SegmentQueryDecoratorTest extends IntegrationTestCase $this->assertStringStartsNotWith("/* idSegments", $sql); } else { $this->assertStringStartsWith($expectedPrefix, $sql); + $this->assertEquals(1, substr_count($sql, 'SELECT')); } } public function getTestDataForSegmentSqlTest() { return array( - array('countryCode==fr', null, '/* idSegments = [2] */'), - array('visitCount<2', null, '/* idSegments = [1, 3, 4, 5] */'), + array('countryCode==fr', null, 'SELECT /* idSegments = [2] */'), + array('visitCount<2', null, 'SELECT /* idSegments = [1, 3, 4, 5] */'), array('', null, null), - array('countryCode!=fr', null, '/* idSegments = [6] */'), + array('countryCode!=fr', null, 'SELECT /* idSegments = [6] */'), - array('', 'archivephp', '/* trigger = CronArchive */'), - array('countryCode!=fr', 'archivephp', '/* trigger = CronArchive, idSegments = [6] */'), + array('', 'archivephp', 'SELECT /* trigger = CronArchive */'), + array('countryCode!=fr', 'archivephp', 'SELECT /* trigger = CronArchive, idSegments = [6] */'), array('', 'garbage', null), - array('countryCode!=fr', 'garbage', '/* idSegments = [6] */'), + array('countryCode!=fr', 'garbage', 'SELECT /* idSegments = [6] */'), ); } -} \ No newline at end of file +} diff --git a/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php b/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php index 1f7b6a29c1..593bac5bed 100644 --- a/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php +++ b/plugins/SegmentEditor/tests/Unit/SegmentQueryDecoratorTest.php @@ -68,7 +68,8 @@ class SegmentQueryDecoratorTest extends \PHPUnit\Framework\TestCase $query = $this->decorator->getSelectQueryString($expression, '*', 'log_visit', '', array(), '', '', ''); - $this->assertStringStartsWith('/* idSegments = [3] */', $query['sql']); + $this->assertStringStartsWith('SELECT /* idSegments = [3] */', $query['sql']); + $this->assertEquals(1, substr_count($query['sql'], 'SELECT')); } public function test_getSelectQueryString_DecoratesSql_WhenMultipleStoredSegmentsMatchUsedSegment() @@ -78,7 +79,8 @@ class SegmentQueryDecoratorTest extends \PHPUnit\Framework\TestCase $query = $this->decorator->getSelectQueryString($expression, '*', 'log_visit', '', array(), '', '', ''); - $this->assertStringStartsWith('/* idSegments = [2, 4] */', $query['sql']); + $this->assertStringStartsWith('SELECT /* idSegments = [2, 4] */', $query['sql']); + $this->assertEquals(1, substr_count($query['sql'], 'SELECT')); } private function getMockSegmentEditorService() -- cgit v1.2.3