Skip to content

Commit 8e0af42

Browse files
authored
Merge pull request #131 from keboola/AJDA-1176-ondra-fix
[AJDA-1176] Create data file if not exists
2 parents 577c28e + 099e09a commit 8e0af42

13 files changed

Lines changed: 63 additions & 252 deletions

File tree

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,6 @@ parameters:
840840
count: 1
841841
path: tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php
842842

843-
-
844-
message: "#^Method Keboola\\\\GoogleAnalyticsExtractor\\\\ApplicationTest\\:\\:assertManifestContainsColumns\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#"
845-
count: 1
846-
path: tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php
847-
848843
-
849844
message: "#^Method Keboola\\\\GoogleAnalyticsExtractor\\\\ApplicationTest\\:\\:getConfig\\(\\) return type has no value type specified in iterable type array\\.$#"
850845
count: 1
@@ -855,11 +850,6 @@ parameters:
855850
count: 1
856851
path: tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php
857852

858-
-
859-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
860-
count: 1
861-
path: tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php
862-
863853
-
864854
message: "#^Parameter \\#2 \\$array of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) expects array\\|ArrayAccess, mixed given\\.$#"
865855
count: 2

src/Extractor/Output.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ public function createCsvFile(string $name): CsvFile
167167
if (!is_dir($outTablesDir)) {
168168
mkdir($outTablesDir, 0777, true);
169169
}
170-
return new CsvFile($this->dataDir . '/out/tables/' . $name . '.csv');
170+
$filename = $this->dataDir . '/out/tables/' . $name . '.csv';
171+
if (!file_exists($filename)) {
172+
touch($filename);
173+
}
174+
return new CsvFile($filename);
171175
}
172176

173177
public function createManifest(

tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -50,72 +50,6 @@ private function getConfig(string $suffix = ''): array
5050
return $config;
5151
}
5252

53-
public function testAppRunDailyWalk(): void
54-
{
55-
$this->config = $this->getConfig('_antisampling');
56-
$this->runProcess();
57-
58-
$dailyWalk = $this->getManifestFiles('dailyWalk');
59-
Assert::assertEquals(1, count($dailyWalk));
60-
61-
foreach ($dailyWalk as $file) {
62-
/** @var $file SplFileInfo */
63-
$this->assertManifestContainsColumns($file->getPathname(), [
64-
'id',
65-
'idProfile',
66-
'date',
67-
'sourceMedium',
68-
'landingPagePath',
69-
'pageviews',
70-
]);
71-
}
72-
}
73-
74-
public function testAppRunAdaptive(): void
75-
{
76-
$this->config = $this->getConfig('_antisampling_adaptive');
77-
$this->runProcess();
78-
79-
$adaptive = $this->getManifestFiles('adaptive');
80-
Assert::assertEquals(1, count($adaptive));
81-
82-
foreach ($adaptive as $file) {
83-
/** @var $file SplFileInfo */
84-
$this->assertManifestContainsColumns($file->getPathname(), [
85-
'id',
86-
'idProfile',
87-
'date',
88-
'sourceMedium',
89-
'landingPagePath',
90-
'pageviews',
91-
]);
92-
}
93-
}
94-
95-
public function testAppRunMCF(): void
96-
{
97-
$this->config = $this->getConfig('_mcf');
98-
$this->runProcess();
99-
100-
$funnelFiles = $this->getManifestFiles('funnel');
101-
Assert::assertEquals(1, count($funnelFiles));
102-
103-
foreach ($funnelFiles as $file) {
104-
/** @var $file SplFileInfo */
105-
$this->assertManifestContainsColumns($file->getPathname(), [
106-
'id',
107-
'idProfile',
108-
'mcf:conversionDate',
109-
'mcf:sourcePath',
110-
'mcf:mediumPath',
111-
'mcf:sourceMedium',
112-
'mcf:totalConversions',
113-
'mcf:totalConversionValue',
114-
'mcf:assistedConversions',
115-
]);
116-
}
117-
}
118-
11953
public function testAppProfilesProperties(): void
12054
{
12155
$this->config = $this->getConfig('_empty');
@@ -183,13 +117,6 @@ private function getManifestFiles(string $queryName): Finder
183117
;
184118
}
185119

186-
private function assertManifestContainsColumns(string $pathname, array $expected): void
187-
{
188-
$manifest = (array) json_decode(file_get_contents($pathname), true, 512, JSON_THROW_ON_ERROR);
189-
Assert::assertArrayHasKey('columns', $manifest);
190-
Assert::assertEquals($expected, $manifest['columns']);
191-
}
192-
193120
public function appRunDataProvider(): Generator
194121
{
195122
yield 'configRow' => [

tests/data/config_antisampling.json

Lines changed: 0 additions & 52 deletions
This file was deleted.

tests/data/config_antisampling_adaptive.json

Lines changed: 0 additions & 53 deletions
This file was deleted.

tests/data/config_mcf.json

Lines changed: 0 additions & 63 deletions
This file was deleted.

tests/functional/download-empty-data/expected/data/out/files/.gitkeep

Whitespace-only changes.

tests/functional/download-empty-data/expected/data/out/tables/empty-data.csv

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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"}]}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"properties/403517979","Website - GA4","accounts/128209249","Keboola Website"

0 commit comments

Comments
 (0)