New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring tests #13863

Merged
merged 1 commit into from Dec 12, 2017
Jump to file or symbol
Failed to load files and symbols.
+47 −45
Diff settings

Always

Just for now

Refactoring tests

Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
  • Loading branch information...
carusogabriel committed Dec 12, 2017
commit d0b3ca5d48832cef59df0899438679704461e33d
@@ -256,7 +256,7 @@ function testArrayRemove()
*/
function testGotoNowhere($page, $whiteList, $expected)
{
$this->assertTrue($expected === Core::checkPageValidity($page, $whiteList));
$this->assertSame($expected, Core::checkPageValidity($page, $whiteList));
}
/**
@@ -605,7 +605,7 @@ public function testVarNotSetNoDefault()
{
// $in is not set!
$out = Core::ifSetOr($in);
$this->assertEquals($out, null);
$this->assertNull($out);
}
/**
@@ -164,7 +164,7 @@ public function testCheckSavedErrors()
'checkSavedErrors',
array()
);
$this->assertTrue(!isset($_SESSION['errors']));
$this->assertArrayNotHasKey('errors', $_SESSION);
}
/**
@@ -209,9 +209,9 @@ public function testSliceErrors()
1,
$this->object->countErrors()
);
$this->assertEquals(
$this->assertCount(
1,
count($this->object->sliceErrors(0))
$this->object->sliceErrors(0)
);
$this->assertEquals(
0,
@@ -174,9 +174,9 @@ public function testGetBacktrace()
$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));
}
}
@@ -104,10 +104,7 @@ public function testConstructor()
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)
@@ -50,7 +50,7 @@ public function testAvailable()
$langs = $this->manager->availableLocales();
$this->assertEquals(2, count($langs));
$this->assertCount(2, $langs);
$this->assertContains('cs', $langs);
$GLOBALS['cfg']['FilterLanguages'] = '';
}
@@ -106,11 +106,11 @@ public function testLanguages()
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());
}
@@ -108,10 +108,7 @@ public function testGetData()
'testFunction',
$functions
);
$this->assertEquals(
1,
count($functions)
);
$this->assertCount(1, $functions);
$this->assertEmpty($parent->getData('procedures', 0));
$this->assertEmpty($parent->getData('events', 0));
@@ -194,7 +194,7 @@ public function testParents()
public function testRealParent()
{
$parent = NodeFactory::getInstance();
$this->assertEquals($parent->realParent(), false);
$this->assertFalse($parent->realParent());
$child = NodeFactory::getInstance();
$parent->addChild($child);
@@ -419,8 +419,9 @@ public function testLogoutDelete()
$this->object->logOut();
$this->assertFalse(
isset($_COOKIE['pmaAuth-0'])
$this->assertArrayNotHasKey(
'pmaAuth-0',
$_COOKIE
);
}
@@ -445,8 +446,9 @@ public function testLogout()
$this->object->logOut();
$this->assertFalse(
isset($_COOKIE['pmaAuth-1'])
$this->assertArrayNotHasKey(
'pmaAuth-1',
$_COOKIE
);
}
@@ -484,8 +486,9 @@ public function testAuthCheckArbitrary()
$GLOBALS['pma_auth_server']
);
$this->assertFalse(
isset($_COOKIE['pmaAuth-1'])
$this->assertArrayNotHasKey(
'pmaAuth-1',
$_COOKIE
);
}
@@ -680,12 +683,14 @@ public function testAuthSetUser()
$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';
@@ -295,8 +295,9 @@ public function testAuthSetUser()
$GLOBALS['cfg']['Server']['password']
);
$this->assertFalse(
isset($_SERVER['PHP_AUTH_PW'])
$this->assertArrayNotHasKey(
'PHP_AUTH_PW',
$_SERVER
);
$this->assertEquals(
@@ -196,8 +196,9 @@ public function testAuthCheckToken()
session_id()
);
$this->assertFalse(
isset($_SESSION['LAST_SIGNON_URL'])
$this->assertArrayNotHasKey(
'LAST_SIGNON_URL',
$_SESSION
);
}
@@ -176,8 +176,9 @@ public function testSetProperties()
*/
public function testExportHeader()
{
$this->assertTrue(
isset($GLOBALS['ods_buffer'])
$this->assertArrayHasKey(
'ods_buffer',
$GLOBALS
);
$this->assertTrue(
@@ -59,9 +59,9 @@ public function testGetItemType()
*/
public function testCountable()
{
$this->assertEquals(
$this->assertCount(
0,
count($this->object)
$this->object
);
}
@@ -410,7 +410,7 @@ public function testGetQueryFromRequest($request, $query, $num_err)
$GLOBALS['dbi'] = $dbi;
$this->assertEquals($query, Events::getQueryFromRequest());
$this->assertEquals($num_err, count($errors));
$this->assertCount($num_err, $errors);
}
/**
@@ -1117,7 +1117,7 @@ public function testGetQueryFromRequest($request, $query, $num_err)
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;
@@ -336,7 +336,7 @@ public function testGetQueryFromRequest(
$GLOBALS['server'] = 1;
$this->assertEquals($query, Triggers::getQueryFromRequest());
$this->assertEquals($num_err, count($errors));
$this->assertCount($num_err, $errors);
}
/**
@@ -280,9 +280,9 @@ public function testRemoveRequestVars()
$_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);
}
}
@@ -247,9 +247,9 @@ public function testBackends()
$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;
}
ProTip! Use n and p to navigate between commits in a pull request.