$this->assertFalse(
wfRandomString() == wfRandomString()
);
- $this->assertEquals(
- strlen( wfRandomString( 10 ) ), 10
- );
- $this->assertTrue(
- preg_match( '/^[0-9a-f]+$/i', wfRandomString() ) === 1
- );
+ $this->assertSame( 10, strlen( wfRandomString( 10 ) ), 'length' );
+ $this->assertSame( 1, preg_match( '/^[0-9a-f]+$/i', wfRandomString() ), 'pattern' );
}
/**
*/
public static function getMutableTestUser( $testName, $groups = [] ) {
$id = self::getNextId();
- $password = wfRandomString( 20 );
+ $password = "password_for_test_user_id_{$id}";
$testUser = new TestUser(
"TestUser $testName $id", // username
"Name $id", // real name
$password = 'UTSysopPassword';
} else {
$username = "TestUser $id";
- $password = wfRandomString( 20 );
+ $password = "password_for_test_user_id_{$id}";
}
self::$testUsers[$key] = $testUser = new TestUser(
$username, // username
*/
public function testConstructor( $prefix ) {
$var = $prefix . 'GlobalVarConfigTest';
- $rand = wfRandomString();
- $this->setMwGlobals( $var, $rand );
+ $this->setMwGlobals( $var, 'testvalue' );
$config = new GlobalVarConfig( $prefix );
$this->assertInstanceOf( GlobalVarConfig::class, $config );
- $this->assertEquals( $rand, $config->get( 'GlobalVarConfigTest' ) );
+ $this->assertEquals( 'testvalue', $config->get( 'GlobalVarConfigTest' ) );
}
public static function provideConstructor() {
* @covers GlobalVarConfig::hasWithPrefix
*/
public function testHas() {
- $this->setMwGlobals( 'wgGlobalVarConfigTestHas', wfRandomString() );
+ $this->setMwGlobals( 'wgGlobalVarConfigTestHas', 'testvalue' );
$config = new GlobalVarConfig();
$this->assertTrue( $config->has( 'GlobalVarConfigTestHas' ) );
$this->assertFalse( $config->has( 'GlobalVarConfigTestNotHas' ) );
'name' => 'localtesting',
'lockManager' => LockManagerGroup::singleton()->get( 'fsLockManager' ),
'parallelize' => 'implicit',
- 'wikiId' => wfWikiID() . wfRandomString(),
+ 'wikiId' => 'testdb',
'backends' => [
[
'name' => 'localmultitesting1',
'wikiId' => wfWikiID()
] ) );
- $name = wfRandomString( 300 );
-
$input = [
'headers' => [
- 'content-Disposition' => FileBackend::makeContentDisposition( 'inline', $name ),
+ 'content-Disposition' => FileBackend::makeContentDisposition( 'inline', 'name' ),
'Content-dUration' => 25.6,
'X-LONG-VALUE' => str_pad( '0', 300 ),
'CONTENT-LENGTH' => 855055,
];
$expected = [
'headers' => [
- 'content-disposition' => FileBackend::makeContentDisposition( 'inline', $name ),
+ 'content-disposition' => FileBackend::makeContentDisposition( 'inline', 'name' ),
'content-duration' => 25.6,
'content-length' => 855055
]
$this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
$this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
- $id = wfRandomString( 32 );
- $root1 = Job::newRootJobParams( "nulljobspam:$id" ); // task ID/timestamp
+ $root1 = Job::newRootJobParams( "nulljobspam:testId" ); // task ID/timestamp
for ( $i = 0; $i < 5; ++$i ) {
$this->assertNull( $queue->push( $this->newJob( 0, $root1 ) ), "Push worked ($desc)" );
}
* @covers MultiWriteBagOStuff::doWrite
*/
public function testSetImmediate() {
- $key = wfRandomString();
- $value = wfRandomString();
+ $key = 'key';
+ $value = 'value';
$this->cache->set( $key, $value );
// Set in tier 1
* @covers MultiWriteBagOStuff
*/
public function testSyncMerge() {
- $key = wfRandomString();
- $value = wfRandomString();
+ $key = 'keyA';
+ $value = 'value';
$func = function () use ( $value ) {
return $value;
};
// Set in tier 1
$this->assertEquals( $value, $this->cache1->get( $key ), 'Written to tier 1' );
// Not yet set in tier 2
- $this->assertEquals( false, $this->cache2->get( $key ), 'Not written to tier 2' );
+ $this->assertFalse( $this->cache2->get( $key ), 'Not written to tier 2' );
$dbw->commit();
// Set in tier 2
$this->assertEquals( $value, $this->cache2->get( $key ), 'Written to tier 2' );
- $key = wfRandomString();
+ $key = 'keyB';
$dbw->begin();
$this->cache->merge( $key, $func, 0, 1, BagOStuff::WRITE_SYNC );
* @covers MultiWriteBagOStuff::set
*/
public function testSetDelayed() {
- $key = wfRandomString();
- $value = (object)[ 'v' => wfRandomString() ];
+ $key = 'key';
+ $value = (object)[ 'v' => 'saved value' ];
$expectValue = clone $value;
// XXX: DeferredUpdates bound to transactions in CLI mode
$this->cache->set( $key, $value );
// Test that later changes to $value don't affect the saved value (e.g. T168040)
- $value->v = 'bogus';
+ $value->v = 'other value';
// Set in tier 1
$this->assertEquals( $expectValue, $this->cache1->get( $key ), 'Written to tier 1' );
// Not yet set in tier 2
- $this->assertEquals( false, $this->cache2->get( $key ), 'Not written to tier 2' );
+ $this->assertFalse( $this->cache2->get( $key ), 'Not written to tier 2' );
$dbw->commit();
* @covers ReplicatedBagOStuff::set
*/
public function testSet() {
- $key = wfRandomString();
- $value = wfRandomString();
+ $key = 'a key';
+ $value = 'a value';
$this->cache->set( $key, $value );
// Write to master.
- $this->assertEquals( $this->writeCache->get( $key ), $value );
+ $this->assertEquals( $value, $this->writeCache->get( $key ) );
// Don't write to replica. Replication is deferred to backend.
- $this->assertEquals( $this->readCache->get( $key ), false );
+ $this->assertFalse( $this->readCache->get( $key ) );
}
/**
* @covers ReplicatedBagOStuff::get
*/
public function testGet() {
- $key = wfRandomString();
+ $key = 'a key';
- $write = wfRandomString();
+ $write = 'one value';
$this->writeCache->set( $key, $write );
- $read = wfRandomString();
+ $read = 'another value';
$this->readCache->set( $key, $read );
// Read from replica.
- $this->assertEquals( $this->cache->get( $key ), $read );
+ $this->assertEquals( $read, $this->cache->get( $key ) );
}
/**
* @covers ReplicatedBagOStuff::get
*/
public function testGetAbsent() {
- $key = wfRandomString();
- $value = wfRandomString();
+ $key = 'a key';
+ $value = 'a value';
$this->writeCache->set( $key, $value );
// Don't read from master. No failover if value is absent.
- $this->assertEquals( $this->cache->get( $key ), false );
+ $this->assertFalse( $this->cache->get( $key ) );
}
}