assertStringContainsString('
assertStringContainsString("
dummyDbi = $this->createDbiDummy();
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
$GLOBALS['dbi'] = $this->dbi;
$GLOBALS['cfg']['LimitChars'] = 50;
$GLOBALS['cfg']['ServerDefault'] = 'PMA_server';
$GLOBALS['cfg']['ShowHint'] = true;
$GLOBALS['cfg']['CharEditing'] = '';
$GLOBALS['cfg']['ActionLinksMode'] = 'icons';
$GLOBALS['db'] = 'PMA_db';
$GLOBALS['table'] = 'PMA_table';
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$_POST['change_column'] = null;
//$_SESSION
//mock DBI
$dbi = $this->getMockBuilder(DatabaseInterface::class)
->disableOriginalConstructor()
->getMock();
$dbi->types = new Types($dbi);
$GLOBALS['dbi'] = $dbi;
// set expectations
$dbi->expects($this->any())
->method('selectDb')
->willReturn(true);
$dbi->expects($this->any())
->method('getColumns')
->willReturn([
'id' => ['Field' => 'id', 'Type' => 'integer'],
'col1' => ['Field' => 'col1', 'Type' => 'varchar(100)'],
'col2' => ['Field' => 'col2', 'Type' => 'DATETIME'],
]);
$dbi->expects($this->any())
->method('getColumnNames')
->willReturn(['id', 'col1', 'col2']);
$map = [
['PMA_db', 'PMA_table1', Connection::TYPE_USER, []],
['PMA_db', 'PMA_table', Connection::TYPE_USER, [['Key_name' => 'PRIMARY', 'Column_name' => 'id']]],
[
'PMA_db',
'PMA_table2',
Connection::TYPE_USER,
[['Key_name' => 'PRIMARY','Column_name' => 'id'], ['Key_name' => 'PRIMARY','Column_name' => 'col1']],
],
];
$dbi->expects($this->any())
->method('getTableIndexes')
->willReturnMap($map);
$dbi->expects($this->any())
->method('tryQuery')
->willReturn($this->createStub(DummyResult::class));
$dbi->expects($this->any())
->method('fetchResult')
->willReturn([0]);
$this->normalization = new Normalization($dbi, new Relation($dbi), new Transformations(), new Template());
}
/**
* Test for getHtmlForColumnsList
*/
public function testGetHtmlForColumnsList(): void
{
$db = 'PMA_db';
$table = 'PMA_table';
$this->assertStringContainsString(
'',
$this->normalization->getHtmlForColumnsList($table, $db),
);
$this->assertEquals(
'col1 [ varchar(100) ]
',
$this->normalization->getHtmlForColumnsList($table, $db, 'String', 'checkbox'),
);
}
/**
* Test for getHtmlForCreateNewColumn
*/
public function testGetHtmlForCreateNewColumn(): void
{
$GLOBALS['cfg']['BrowseMIME'] = true;
$GLOBALS['cfg']['MaxRows'] = 25;
$GLOBALS['col_priv'] = false;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['dbi'] = $this->dbi;
$db = 'testdb';
$table = 'mytable';
$numFields = 1;
$normalization = new Normalization(
$this->dbi,
new Relation($this->dbi),
new Transformations(),
new Template(),
);
$result = $normalization->getHtmlForCreateNewColumn($numFields, $db, $table);
$this->assertStringContainsString('