Skip to content

Commit

Permalink
Replace readAttribute() and assertAttributeEquals()
Browse files Browse the repository at this point in the history
assertAttributeEquals() is deprecated and will be removed in PHPUnit 9.
readAttribute() is deprecated and will be removed in PHPUnit 9.

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Feb 24, 2019
1 parent 39141e7 commit 74105ab
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
15 changes: 12 additions & 3 deletions test/classes/Config/FormDisplayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ protected function tearDown(): void
*/
public function testFormDisplayContructor()
{
$reflection = new ReflectionProperty(FormDisplay::class, '_jsLangStrings');
$reflection->setAccessible(true);

$this->assertCount(
5,
$this->readAttribute($this->object, '_jsLangStrings')
$reflection->getValue($this->object)
);
}

Expand Down Expand Up @@ -95,20 +98,26 @@ public function testRegisterForm()
$_forms['pma_testform']
);

$attrSystemPaths = $reflection->getProperty('_systemPaths');
$attrSystemPaths->setAccessible(true);

$this->assertEquals(
[
"Servers/2/test" => "Servers/1/test",
"Servers/2/:group:end:0" => "Servers/1/:group:end:0",
],
$this->readAttribute($this->object, '_systemPaths')
$attrSystemPaths->getValue($this->object)
);

$attrTranslatedPaths = $reflection->getProperty('_translatedPaths');
$attrTranslatedPaths->setAccessible(true);

$this->assertEquals(
[
"Servers/2/test" => "Servers-2-test",
"Servers/2/:group:end:0" => "Servers-2-:group:end:0",
],
$this->readAttribute($this->object, '_translatedPaths')
$attrTranslatedPaths->getValue($this->object)
);
}

Expand Down
7 changes: 2 additions & 5 deletions test/classes/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,11 +837,8 @@ public function testGetUserValue()
public function testGetThemeUniqueValue()
{
$partial_sum = (
Assert::readAttribute($this->object, 'source_mtime') +
Assert::readAttribute(
$this->object,
'default_source_mtime'
) +
$this->object->source_mtime +
$this->object->default_source_mtime +
$this->object->get('user_preferences_mtime') +
$GLOBALS['PMA_Theme']->mtime_info +
$GLOBALS['PMA_Theme']->filesize_info
Expand Down
10 changes: 5 additions & 5 deletions test/classes/HeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ public function testGetMessage()
*/
public function testDisableWarnings()
{
$reflection = new \ReflectionProperty(Header::class, '_warningsEnabled');
$reflection->setAccessible(true);

$header = new Header();
$header->disableWarnings();
$this->assertAttributeEquals(
false,
'_warningsEnabled',
$header
);

$this->assertFalse($reflection->getValue($header));
}

/**
Expand Down
24 changes: 9 additions & 15 deletions test/classes/ScriptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,12 @@ public function testGetFiles()
*/
public function testAddFile()
{
$reflection = new \ReflectionProperty(Scripts::class, '_files');
$reflection->setAccessible(true);

// Assert empty _files property of
// Scripts
$this->assertAttributeEquals(
[],
'_files',
$this->object
);
$this->assertEquals([], $reflection->getValue($this->object));

// Add one script file
$file = 'common.js';
Expand All @@ -189,11 +188,7 @@ public function testAddFile()
],
];
$this->object->addFile($file);
$this->assertAttributeEquals(
$_files,
'_files',
$this->object
);
$this->assertEquals($_files, $reflection->getValue($this->object));
}

/**
Expand All @@ -203,6 +198,9 @@ public function testAddFile()
*/
public function testAddFiles()
{
$reflection = new \ReflectionProperty(Scripts::class, '_files');
$reflection->setAccessible(true);

$filenames = [
'common.js',
'sql.js',
Expand All @@ -221,10 +219,6 @@ public function testAddFiles()
],
];
$this->object->addFiles($filenames);
$this->assertAttributeEquals(
$_files,
'_files',
$this->object
);
$this->assertEquals($_files, $reflection->getValue($this->object));
}
}
5 changes: 4 additions & 1 deletion test/classes/TrackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ protected function setUp(): void
*/
public function testEnabled()
{
$reflection = new \ReflectionProperty(Tracker::class, 'enabled');
$reflection->setAccessible(true);

Tracker::enable();
$this->assertTrue(
Assert::readAttribute('PhpMyAdmin\Tracker', 'enabled')
$reflection->getValue()
);
}

Expand Down

0 comments on commit 74105ab

Please sign in to comment.