Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Dec 1, 2023
1 parent e945dec commit def2cd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions core/Segment.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,13 @@ protected function getCleanedExpression(array $expression): array
$matchType = $expression[SegmentExpression::INDEX_OPERAND_OPERATOR];
$value = $expression[SegmentExpression::INDEX_OPERAND_VALUE];

$segmentsList = Context::changeIdSite(implode(',', $this->idSites ?: []), function () {
return SegmentsList::get();
});
if (empty($this->idSites)) {
$segmentsList = SegmentsList::get();
} else {
$segmentsList = Context::changeIdSite(implode(',', $this->idSites), function () {
return SegmentsList::get();
});
}
$segmentObject = $segmentsList->getSegment($name);

$sqlName = $segmentObject ? $segmentObject->getSqlSegment() : null;
Expand Down
12 changes: 6 additions & 6 deletions tests/PHPUnit/Integration/SegmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ public function getCommonSubqueryTestData(): iterable
$segmentFrom = '2020-02-02 02:00:00';

$whereSingle = '(log_visit.idvisit NOT IN(SELECT log_visit.idvisit FROM log_visit AS log_visit LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit WHERE(log_visit.visit_last_action_time >= ?)AND(log_link_visit_action.idaction_name = ?)))';
$whereMultiAnd = '(log_visit.idvisit NOT IN(SELECT log_visit.idvisit FROM log_visit AS log_visit LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit WHERE(log_visit.visit_last_action_time >= ?)AND(log_link_visit_action.idaction_name = ?)))AND(log_visit.idvisit NOT IN(SELECT log_visit.idvisit FROM log_visit AS log_visit LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit WHERE(log_visit.visit_last_action_time >= ?)AND(log_link_visit_action.idaction_name = ?)))';
$whereMultiOr = '((log_visit.idvisit NOT IN(SELECT log_visit.idvisit FROM log_visit AS log_visit LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit WHERE(log_visit.visit_last_action_time >= ?)AND(log_link_visit_action.idaction_name = ?)))OR(log_visit.idvisit NOT IN(SELECT log_visit.idvisit FROM log_visit AS log_visit LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit WHERE(log_visit.visit_last_action_time >= ?)AND(log_link_visit_action.idaction_name = ?))))';
$whereMultiAnd = '(log_visit.idvisit NOT IN(SELECT log_visit.idvisit FROM log_visit AS log_visit LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit WHERE(log_visit.visit_last_action_time >= ?)AND((log_link_visit_action.idaction_name = ? OR log_link_visit_action.idaction_name = ?))))';
$whereMultiOr = '(log_visit.idvisit NOT IN(SELECT log_visit.idvisit FROM log_visit AS log_visit LEFT JOIN log_link_visit_action AS log_link_visit_action ON log_link_visit_action.idvisit = log_visit.idvisit WHERE(log_visit.visit_last_action_time >= ?)AND(log_link_visit_action.idaction_name = ? AND log_link_visit_action.idaction_name = ?)))';

yield 'normal segment' => [
'pageTitle!=a',
Expand Down Expand Up @@ -235,7 +235,7 @@ public function getCommonSubqueryTestData(): iterable
$segmentFrom,
[
'where' => $whereMultiAnd,
'bind' => [$segmentFrom, '1', $segmentFrom, '2'],
'bind' => [$segmentFrom, '1', '2'],
],
];

Expand All @@ -244,7 +244,7 @@ public function getCommonSubqueryTestData(): iterable
$segmentFrom,
[
'where' => $whereMultiOr,
'bind' => [$segmentFrom, '1', $segmentFrom, '2'],
'bind' => [$segmentFrom, '1', '2'],
],
];

Expand All @@ -253,7 +253,7 @@ public function getCommonSubqueryTestData(): iterable
$segmentFrom,
[
'where' => $whereMultiAnd,
'bind' => [$segmentFrom, '3', $segmentFrom, '4'],
'bind' => [$segmentFrom, '3', '4'],
],
];

Expand All @@ -262,7 +262,7 @@ public function getCommonSubqueryTestData(): iterable
$segmentFrom,
[
'where' => $whereMultiOr,
'bind' => [$segmentFrom, '3', $segmentFrom, '4'],
'bind' => [$segmentFrom, '3', '4'],
],
];
}
Expand Down

0 comments on commit def2cd7

Please sign in to comment.