Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,6 @@ parameters:
count: 1
path: tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php

-
message: "#^Method Keboola\\\\GoogleAnalyticsExtractor\\\\ApplicationTest\\:\\:assertManifestContainsColumns\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#"
count: 1
path: tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php

-
message: "#^Method Keboola\\\\GoogleAnalyticsExtractor\\\\ApplicationTest\\:\\:getConfig\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -855,11 +850,6 @@ parameters:
count: 1
path: tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php

-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php

-
message: "#^Parameter \\#2 \\$array of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) expects array\\|ArrayAccess, mixed given\\.$#"
count: 2
Expand Down
6 changes: 5 additions & 1 deletion src/Extractor/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ public function createCsvFile(string $name): CsvFile
if (!is_dir($outTablesDir)) {
mkdir($outTablesDir, 0777, true);
}
return new CsvFile($this->dataDir . '/out/tables/' . $name . '.csv');
$filename = $this->dataDir . '/out/tables/' . $name . '.csv';
if (!file_exists($filename)) {
touch($filename);
}
return new CsvFile($filename);
}

public function createManifest(
Expand Down
73 changes: 0 additions & 73 deletions tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,72 +50,6 @@ private function getConfig(string $suffix = ''): array
return $config;
}

public function testAppRunDailyWalk(): void
{
$this->config = $this->getConfig('_antisampling');
$this->runProcess();

$dailyWalk = $this->getManifestFiles('dailyWalk');
Assert::assertEquals(1, count($dailyWalk));

foreach ($dailyWalk as $file) {
/** @var $file SplFileInfo */
$this->assertManifestContainsColumns($file->getPathname(), [
'id',
'idProfile',
'date',
'sourceMedium',
'landingPagePath',
'pageviews',
]);
}
}

public function testAppRunAdaptive(): void
{
$this->config = $this->getConfig('_antisampling_adaptive');
$this->runProcess();

$adaptive = $this->getManifestFiles('adaptive');
Assert::assertEquals(1, count($adaptive));

foreach ($adaptive as $file) {
/** @var $file SplFileInfo */
$this->assertManifestContainsColumns($file->getPathname(), [
'id',
'idProfile',
'date',
'sourceMedium',
'landingPagePath',
'pageviews',
]);
}
}

public function testAppRunMCF(): void
{
$this->config = $this->getConfig('_mcf');
$this->runProcess();

$funnelFiles = $this->getManifestFiles('funnel');
Assert::assertEquals(1, count($funnelFiles));

foreach ($funnelFiles as $file) {
/** @var $file SplFileInfo */
$this->assertManifestContainsColumns($file->getPathname(), [
'id',
'idProfile',
'mcf:conversionDate',
'mcf:sourcePath',
'mcf:mediumPath',
'mcf:sourceMedium',
'mcf:totalConversions',
'mcf:totalConversionValue',
'mcf:assistedConversions',
]);
}
}

public function testAppProfilesProperties(): void
{
$this->config = $this->getConfig('_empty');
Expand Down Expand Up @@ -183,13 +117,6 @@ private function getManifestFiles(string $queryName): Finder
;
}

private function assertManifestContainsColumns(string $pathname, array $expected): void
{
$manifest = (array) json_decode(file_get_contents($pathname), true, 512, JSON_THROW_ON_ERROR);
Assert::assertArrayHasKey('columns', $manifest);
Assert::assertEquals($expected, $manifest['columns']);
}

public function appRunDataProvider(): Generator
{
yield 'configRow' => [
Expand Down
52 changes: 0 additions & 52 deletions tests/data/config_antisampling.json

This file was deleted.

53 changes: 0 additions & 53 deletions tests/data/config_antisampling_adaptive.json

This file was deleted.

63 changes: 0 additions & 63 deletions tests/data/config_mcf.json

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"destination":"in.c-keboola-ex-google-analytics-v4-01k6mq8atddf0xbr48p2b9st4h.empty-data","incremental":true,"columns":["id","idProperty","campaignId","campaignName","city","cityId","active1DayUsers","active28DayUsers"],"primary_key":["id"],"column_metadata":{"id":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"idProperty":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"campaignId":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"campaignName":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"city":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"cityId":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"active1DayUsers":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"active28DayUsers":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}]}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"properties/403517979","Website - GA4","accounts/128209249","Keboola Website"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"destination":"in.c-keboola-ex-google-analytics-v4-01k6mq8atddf0xbr48p2b9st4h.properties","incremental":true,"columns":["propertyKey","propertyName","accountKey","accountName"],"primary_key":["propertyKey"],"column_metadata":{"propertyKey":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"propertyName":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"accountKey":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}],"accountName":[{"key":"KBC.datatype.nullable","value":true},{"key":"KBC.datatype.basetype","value":"STRING"}]}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"metric":"API Calls","value":1}]
54 changes: 54 additions & 0 deletions tests/functional/download-empty-data/source/data/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"authorization": {
"oauth_api": {
"credentials": {
"appKey": "%env(string:CLIENT_ID)%",
"#appSecret": "%env(string:CLIENT_SECRET)%",
"#data": "%env(string:CREDENTIALS_DATA)%"
}
}
},
"parameters": {
"outputTable": "empty-data",
"query": {
"metrics": [
{
"name": "active1DayUsers"
},
{
"name": "active28DayUsers"
}
],
"dimensions": [
{
"name": "campaignId"
},
{
"name": "campaignName"
},
{
"name": "city"
},
{
"name": "cityId"
}
],
"dateRanges": [
{
"startDate": "2015-08-14",
"endDate": "2015-08-15"
}
]
},
"endpoint": "data-api",
"outputBucket": "in.c-keboola-ex-google-analytics-v4-01k6mq8atddf0xbr48p2b9st4h",
"properties": [
{
"accountKey": "accounts/128209249",
"accountName": "Keboola Website",
"propertyKey": "properties/403517979",
"propertyName": "Website - GA4"
}
]
}
}