1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-05 05:02:44 +02:00
This commit is contained in:
Cameron 2018-02-23 14:25:40 -08:00
commit e6ef6210cf
3 changed files with 79 additions and 5 deletions

2
e107

@ -1 +1 @@
Subproject commit e92c6789c51c9b653153efe555d1ded9ffbff49f
Subproject commit 840859a32f5e7c6d579f1b643e99ed30d30d1fd7

View File

@ -289,11 +289,13 @@ class cPanelDeployer
private static function prune_mysql_databases($dbs, $ids, $cPanel)
{
$prefix = $cPanel->user."_".self::TEST_PREFIX;
foreach ($dbs as $db)
{
$db = (array) $db;
$offset = strpos($db['db'], self::TEST_PREFIX);
$questionable_db = substr($db['db'], $offset);
if (substr($db['db'], 0, strlen($prefix)) !== $prefix)
continue;
$questionable_db = substr($db['db'], strlen($prefix));
if (!in_array($questionable_db, $ids))
{
self::println("Deleting expired MySQL database \"".$db['db']."\"");
@ -304,11 +306,13 @@ class cPanelDeployer
private static function prune_mysql_users($users, $ids, $cPanel)
{
$prefix = $cPanel->user."_".self::TEST_PREFIX;
foreach ($users as $user)
{
$user = (array) $user;
$offset = strpos($user['user'], self::TEST_PREFIX);
$questionable_user = substr($user['user'], $offset);
if (substr($user['user'], 0, strlen($prefix)) !== $prefix)
continue;
$questionable_user = substr($user['user'], strlen($prefix));
if (!in_array($questionable_user, $ids))
{
self::println("Deleting expired MySQL user \"".$user['user']."\"");

View File

@ -122,6 +122,76 @@ class TreeModelTest extends \Codeception\Test\Unit
$this->assertEquals('163', $tree_model->getParam('db_limit_count'));
$this->assertEquals('79', $tree_model->getParam('db_limit_offset'));
}
public function testMultiFieldCompareWithSortFieldsReturnsExpectedValues()
{
$tree_model = $this->make('e_tree_model');
$class = new \ReflectionClass(get_class($tree_model));
$method = $class->getMethod('multiFieldCmp');
$method->setAccessible(true);
$row1 = array(
'field1' => '0',
'field2' => '-1',
);
$row2 = array(
'field1' => '0',
'field2' => '1',
);
$sort_fields = ['field1', 'field2'];
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
$this->assertEquals(-1, $result);
$row1['field2'] = 1;
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
$this->assertEquals(0, $result);
$row1['field2'] = 2;
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
$this->assertEquals(1, $result);
$row1['field1'] = -1;
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
$this->assertEquals(-1, $result);
$row1['field1'] = 1;
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
$this->assertEquals(1, $result);
}
public function testMultiFieldCompareWithSortFieldReturnsExpectedValues()
{
$tree_model = $this->make('e_tree_model');
$class = new \ReflectionClass(get_class($tree_model));
$method = $class->getMethod('multiFieldCmp');
$method->setAccessible(true);
$row1 = array(
'field1' => '0',
'field2' => '-1',
);
$row2 = array(
'field1' => '0',
'field2' => '1',
);
$sort_field = 'field1';
$result = $method->invoke(null, $row1, $row2, $sort_field, 1);
$this->assertEquals(0, $result);
$row1['field1'] = -1;
$result = $method->invoke(null, $row1, $row2, $sort_field, 1);
$this->assertEquals(-1, $result);
$row1['field1'] = 1;
$result = $method->invoke(null, $row1, $row2, $sort_field, 1);
$this->assertEquals(1, $result);
$row1['field2'] = 1337;
$this->assertEquals(1, $result);
}
protected $sample_rows =
array (
1 =>