Файловый менеджер - Редактировать - /var/www/html/mediawiki-1.43.1/extensions/CheckUser/tests/phpunit/integration/maintenance/PurgeOldDataTest.php
Ðазад
<?php namespace MediaWiki\CheckUser\Tests\Integration\Maintenance; use MediaWiki\CheckUser\Maintenance\PurgeOldData; use MediaWiki\CheckUser\Tests\Integration\CheckUserCommonTraitTest; use MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase; use Wikimedia\Timestamp\ConvertibleTimestamp; /** * @group CheckUser * @group Database * @covers \MediaWiki\CheckUser\Maintenance\PurgeOldData */ class PurgeOldDataTest extends MaintenanceBaseTestCase { use CheckUserCommonTraitTest; /** @inheritDoc */ protected function getMaintenanceClass() { return PurgeOldData::class; } /** * @dataProvider providePruneIPDataData * @todo test for pruning of recent changes */ public function testExecute( $currentTime, $maxCUDataAge, $timestamps, $afterCount ) { $this->setMwGlobals( [ 'wgCUDMaxAge' => $maxCUDataAge, 'wgCheckUserEventTablesMigrationStage' => SCHEMA_COMPAT_NEW ] ); $logEntryCutoff = $currentTime - $maxCUDataAge; foreach ( $timestamps as $timestamp ) { ConvertibleTimestamp::setFakeTime( $timestamp ); $expectedRow = []; // Insertion into cu_changes $this->commonTestsUpdateCheckUserData( self::getDefaultRecentChangeAttribs(), [], $expectedRow ); // Insertion into cu_private_event $this->commonTestsUpdateCheckUserData( array_merge( self::getDefaultRecentChangeAttribs(), [ 'rc_type' => RC_LOG, 'rc_log_type' => '' ] ), [], $expectedRow ); // Insertion into cu_log_event $logId = $this->newLogEntry(); $this->commonTestsUpdateCheckUserData( array_merge( self::getDefaultRecentChangeAttribs(), [ 'rc_type' => RC_LOG, 'rc_logid' => $logId ] ), [], $expectedRow ); } $this->assertRowCount( count( $timestamps ), 'cu_changes', 'cuc_id', 'cu_changes was not set up correctly for the test.' ); $this->assertRowCount( count( $timestamps ), 'cu_private_event', 'cupe_id', 'cu_private_event was not set up correctly for the test.' ); $this->assertRowCount( count( $timestamps ), 'cu_log_event', 'cule_id', 'cu_log_event was not set up correctly for the test.' ); ConvertibleTimestamp::setFakeTime( $currentTime ); ( new PurgeOldData() )->execute(); // Check that all the old entries are gone $logEntryCutoffForDBComparison = $this->getDb()->addQuotes( $this->getDb()->timestamp( $logEntryCutoff ) ); $this->assertRowCount( 0, 'cu_changes', 'cuc_id', 'cu_changes has stale entries after calling pruneIPData.', [ "cuc_timestamp < $logEntryCutoffForDBComparison" ] ); $this->assertRowCount( 0, 'cu_private_event', 'cupe_id', 'cu_private_event has stale entries after calling pruneIPData.', [ "cupe_timestamp < $logEntryCutoffForDBComparison" ] ); $this->assertRowCount( 0, 'cu_log_event', 'cule_id', 'cu_log_event has stale entries after calling pruneIPData.', [ "cule_timestamp < $logEntryCutoffForDBComparison" ] ); // Assert that no still in date entries were removed $this->assertRowCount( $afterCount, 'cu_changes', 'cuc_id', 'cu_changes is missing rows that were not stale after calling pruneIPData.' ); $this->assertRowCount( $afterCount, 'cu_private_event', 'cupe_id', 'cu_private_event is missing rows that were not stale after calling pruneIPData.' ); $this->assertRowCount( $afterCount, 'cu_log_event', 'cule_id', 'cu_log_event is missing rows that were not stale after calling pruneIPData.' ); } public static function providePruneIPDataData() { $currentTime = time(); $defaultMaxAge = 7776000; return [ 'No entries to prune' => [ $currentTime, $defaultMaxAge, [ $currentTime - 2, $currentTime - $defaultMaxAge + 100, $currentTime, $currentTime + 10 ], 4 ], 'Two entries to prune with two to be left' => [ $currentTime, $defaultMaxAge, [ $currentTime - $defaultMaxAge - 20000, $currentTime - $defaultMaxAge - 100, $currentTime, $currentTime + 10 ], 2 ], 'Four entries to prune with no left' => [ $currentTime, $defaultMaxAge, [ $currentTime - $defaultMaxAge - 20000, $currentTime - $defaultMaxAge - 100, $currentTime - $defaultMaxAge - 1, $currentTime - $defaultMaxAge - 100000 ], 0 ] ]; } }
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка