Merge pull request #13863 from carusogabriel/refactoring-tests

Refactoring tests
This commit is contained in:
Maurício Meneghini Fauth 2017-12-12 10:47:03 -02:00 committed by GitHub
commit 8be5072fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 47 additions and 45 deletions

View File

@ -256,7 +256,7 @@ class CoreTest extends PmaTestCase
*/
function testGotoNowhere($page, $whiteList, $expected)
{
$this->assertTrue($expected === Core::checkPageValidity($page, $whiteList));
$this->assertSame($expected, Core::checkPageValidity($page, $whiteList));
}
/**
@ -605,7 +605,7 @@ class CoreTest extends PmaTestCase
{
// $in is not set!
$out = Core::ifSetOr($in);
$this->assertEquals($out, null);
$this->assertNull($out);
}
/**

View File

@ -164,7 +164,7 @@ class ErrorHandlerTest extends PmaTestCase
'checkSavedErrors',
array()
);
$this->assertTrue(!isset($_SESSION['errors']));
$this->assertArrayNotHasKey('errors', $_SESSION);
}
/**
@ -209,9 +209,9 @@ class ErrorHandlerTest extends PmaTestCase
1,
$this->object->countErrors()
);
$this->assertEquals(
$this->assertCount(
1,
count($this->object->sliceErrors(0))
$this->object->sliceErrors(0)
);
$this->assertEquals(
0,

View File

@ -174,9 +174,9 @@ class ErrorTest extends PmaTestCase
$this->object->setBacktrace($bt);
// case: full backtrace
$this->assertEquals(4, count($this->object->getBacktrace()));
$this->assertCount(4, $this->object->getBacktrace());
// case: first 2 frames
$this->assertEquals(2, count($this->object->getBacktrace(2)));
$this->assertCount(2, $this->object->getBacktrace(2));
}
}

View File

@ -104,10 +104,7 @@ class IndexTest extends PmaTestCase
public function testGetIndexChoices()
{
$index_choices = Index::getIndexChoices();
$this->assertEquals(
5,
count($index_choices)
);
$this->assertCount(5, $index_choices);
$this->assertEquals(
'PRIMARY,INDEX,UNIQUE,SPATIAL,FULLTEXT',
implode(",", $index_choices)

View File

@ -50,7 +50,7 @@ class LanguageTest extends PmaTestCase
$langs = $this->manager->availableLocales();
$this->assertEquals(2, count($langs));
$this->assertCount(2, $langs);
$this->assertContains('cs', $langs);
$GLOBALS['cfg']['FilterLanguages'] = '';
}
@ -106,11 +106,11 @@ class LanguageTest extends PmaTestCase
public function testMySQLLocale()
{
$czech = $this->manager->getLanguage('cs');
$this->assertNotEquals($czech, false);
$this->assertNotFalse($czech);
$this->assertEquals('cs_CZ', $czech->getMySQLLocale());
$azerbaijani = $this->manager->getLanguage('az');
$this->assertNotEquals($azerbaijani, false);
$this->assertNotFalse($azerbaijani);
$this->assertEquals('', $azerbaijani->getMySQLLocale());
}

View File

@ -108,10 +108,7 @@ class NodeDatabaseTest extends PmaTestCase
'testFunction',
$functions
);
$this->assertEquals(
1,
count($functions)
);
$this->assertCount(1, $functions);
$this->assertEmpty($parent->getData('procedures', 0));
$this->assertEmpty($parent->getData('events', 0));

View File

@ -194,7 +194,7 @@ class NodeTest extends PmaTestCase
public function testRealParent()
{
$parent = NodeFactory::getInstance();
$this->assertEquals($parent->realParent(), false);
$this->assertFalse($parent->realParent());
$child = NodeFactory::getInstance();
$parent->addChild($child);

View File

@ -419,8 +419,9 @@ class AuthenticationCookieTest extends PmaTestCase
$this->object->logOut();
$this->assertFalse(
isset($_COOKIE['pmaAuth-0'])
$this->assertArrayNotHasKey(
'pmaAuth-0',
$_COOKIE
);
}
@ -445,8 +446,9 @@ class AuthenticationCookieTest extends PmaTestCase
$this->object->logOut();
$this->assertFalse(
isset($_COOKIE['pmaAuth-1'])
$this->assertArrayNotHasKey(
'pmaAuth-1',
$_COOKIE
);
}
@ -484,8 +486,9 @@ class AuthenticationCookieTest extends PmaTestCase
$GLOBALS['pma_auth_server']
);
$this->assertFalse(
isset($_COOKIE['pmaAuth-1'])
$this->assertArrayNotHasKey(
'pmaAuth-1',
$_COOKIE
);
}
@ -680,12 +683,14 @@ class AuthenticationCookieTest extends PmaTestCase
$this->object->rememberCredentials();
$this->assertTrue(
isset($_COOKIE['pmaUser-2'])
$this->assertArrayHasKey(
'pmaUser-2',
$_COOKIE
);
$this->assertTrue(
isset($_COOKIE['pmaAuth-2'])
$this->assertArrayHasKey(
'pmaAuth-2',
$_COOKIE
);
$arr['password'] = 'testPW';

View File

@ -295,8 +295,9 @@ class AuthenticationHttpTest extends PmaTestCase
$GLOBALS['cfg']['Server']['password']
);
$this->assertFalse(
isset($_SERVER['PHP_AUTH_PW'])
$this->assertArrayNotHasKey(
'PHP_AUTH_PW',
$_SERVER
);
$this->assertEquals(

View File

@ -196,8 +196,9 @@ class AuthenticationSignonTest extends PmaTestCase
session_id()
);
$this->assertFalse(
isset($_SESSION['LAST_SIGNON_URL'])
$this->assertArrayNotHasKey(
'LAST_SIGNON_URL',
$_SESSION
);
}

View File

@ -176,8 +176,9 @@ class ExportOdsTest extends PmaTestCase
*/
public function testExportHeader()
{
$this->assertTrue(
isset($GLOBALS['ods_buffer'])
$this->assertArrayHasKey(
'ods_buffer',
$GLOBALS
);
$this->assertTrue(

View File

@ -59,9 +59,9 @@ class OptionsPropertyRootGroupTest extends TestCase
*/
public function testCountable()
{
$this->assertEquals(
$this->assertCount(
0,
count($this->object)
$this->object
);
}

View File

@ -410,7 +410,7 @@ class EventsTest extends TestCase
$GLOBALS['dbi'] = $dbi;
$this->assertEquals($query, Events::getQueryFromRequest());
$this->assertEquals($num_err, count($errors));
$this->assertCount($num_err, $errors);
}
/**

View File

@ -1117,7 +1117,7 @@ class RoutinesTest extends TestCase
unset($_REQUEST);
$_REQUEST = $request;
$this->assertEquals($query, Routines::getQueryFromRequest());
$this->assertEquals($num_err, count($errors));
$this->assertCount($num_err, $errors);
// reset
$GLOBALS['dbi'] = $old_dbi;

View File

@ -336,7 +336,7 @@ class TriggersTest extends TestCase
$GLOBALS['server'] = 1;
$this->assertEquals($query, Triggers::getQueryFromRequest());
$this->assertEquals($num_err, count($errors));
$this->assertCount($num_err, $errors);
}
/**

View File

@ -280,9 +280,9 @@ class SanitizeTest extends TestCase
$_REQUEST['second'] = 1;
$allow_list = array('allow', 'second');
Sanitize::removeRequestVars($allow_list);
$this->assertFalse(isset($_REQUEST['foo']));
$this->assertFalse(isset($_REQUEST['second']));
$this->assertTrue(isset($_REQUEST['allow']));
$this->assertArrayNotHasKey('foo', $_REQUEST);
$this->assertArrayNotHasKey('second', $_REQUEST);
$this->assertArrayHasKey('allow', $_REQUEST);
}
}

View File

@ -247,9 +247,9 @@ class TwoFactorTest extends PmaTestCase
$GLOBALS['cfg']['DBG']['simple2fa'] = true;
$object = new TwoFactor('user');
$backends = $object->getAllBackends();
$this->assertEquals(
$this->assertCount(
count($object->available) + 1,
count($backends)
$backends
);
$GLOBALS['cfg']['DBG']['simple2fa'] = false;
}