Skip to content

Commit e55e019

Browse files
committed
Add test for user count and page count for deleted wikis metrics
Bug: T401471
1 parent 964e8f7 commit e55e019

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

tests/Metrics/WikiMetricsTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,32 @@ public function testSavesEntityCountsCorrectly($expectedItemCount, $expectedProp
363363
'entity_schema_count' => $expectedEntitySchemaCount, // redirects should be ignored
364364
]);
365365
}
366+
367+
public function testSavesCorrectUserCountAndPagesForDeletedWikis() {
368+
$this->markTestSkipped(); // https://phabricator.wikimedia.org/T402189 should be resolved for this test to pass.
369+
$wiki = Wiki::factory()->create([
370+
'domain' => 'somedomain.wikibase.cloud',
371+
]);
372+
$wikiDb = WikiDb::first();
373+
$wikiDb->update(['wiki_id' => $wiki->id]);
374+
Http::fake([
375+
'somedomain.wikibase.cloud' => Http::response([
376+
'query' => [
377+
'statistics' => [
378+
'users' => 5,
379+
'pages' => 10,
380+
],
381+
],
382+
], 200),
383+
]);
384+
$wiki->delete();
385+
(new WikiMetrics)->saveMetrics($wiki);
386+
387+
$this->assertDatabaseHas('wiki_daily_metrics', [
388+
'wiki_id' => $wiki->id,
389+
'pages' => 10,
390+
'total_user_count' => 5,
391+
'is_deleted' => 1,
392+
]);
393+
}
366394
}

0 commit comments

Comments
 (0)