Skip to content

Commit

Permalink
add test to ensure SET STATEMENT FOR MariaDB specific SQL works prope…
Browse files Browse the repository at this point in the history
…rly in MWP
  • Loading branch information
diosmosis committed Dec 25, 2024
1 parent 41a2d46 commit f038b2e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/phpunit/wpmatomo/db/test-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,26 @@ public function test_update_sets_null_values_correctly_when_all_params_are_null(
}

public function test_query_recognizes_mariadb_set_for_queries() {
throw new \Exception( 'unimplemented' );
\Piwik\Config::getInstance()->database['schema'] = 'Mariadb';
\Piwik\Db\Schema::unsetInstance();

$params = new \Piwik\ArchiveProcessor\Parameters(
new \Piwik\Site( 1 ),
\Piwik\Period\Factory::build( 'day', 'today' ),
new \Piwik\Segment( '', [ 1 ] )
);
$log_aggregator = new \Piwik\DataAccess\LogAggregator( $params );

$sql = $log_aggregator->getQueryByDimensionSql( [], false, [], false, false, false, 120, false );

// make sure SQL we're testing has MariaDB specific SQL
$this->assertStringContainsString( 'SET STATEMENT max_statement_time', $sql['sql'] );

// test that the query works in MWP
$statement = $log_aggregator->queryVisitsByDimension( [], false, [], false, false, false, 120, false );
$row = $statement->fetch();

$this->assertIsArray( $row );
}

private function insert_many_values() {
Expand Down

0 comments on commit f038b2e

Please sign in to comment.