From 4f334c7cea0276e41a9d2b615710d202a2185505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 3 Mar 2021 14:04:19 -0300 Subject: [PATCH] Remove dbi mock from ExportXmlTest::testExportData MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- test/classes/Plugins/Export/ExportXmlTest.php | 104 ++++-------------- test/classes/Stubs/DbiDummy.php | 5 + 2 files changed, 28 insertions(+), 81 deletions(-) diff --git a/test/classes/Plugins/Export/ExportXmlTest.php b/test/classes/Plugins/Export/ExportXmlTest.php index a951b05d22bf..01411a26f3e9 100644 --- a/test/classes/Plugins/Export/ExportXmlTest.php +++ b/test/classes/Plugins/Export/ExportXmlTest.php @@ -34,6 +34,7 @@ protected function setUp(): void { parent::setUp(); parent::defineVersionConstants(); + parent::loadDefaultConfig(); $GLOBALS['server'] = 0; $GLOBALS['output_kanji_conversion'] = false; $GLOBALS['buffer_needed'] = false; @@ -44,6 +45,7 @@ protected function setUp(): void $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['cfgRelation']['relation'] = true; $GLOBALS['db'] = 'db'; + $GLOBALS['cfg']['Server']['DisableIS'] = true; $this->object = new ExportXml(); } @@ -455,96 +457,36 @@ public function testExportData(): void $GLOBALS['asfile'] = true; $GLOBALS['output_charset_conversion'] = false; - $dbi = $this->getMockBuilder(DatabaseInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $_table = $this->getMockBuilder(Table::class) - ->disableOriginalConstructor() - ->getMock(); - $_table->expects($this->once()) - ->method('isMerge') - ->will($this->returnValue(false)); - - $dbi->expects($this->any()) - ->method('getTable') - ->will($this->returnValue($_table)); - - $dbi->expects($this->once()) - ->method('getTable') - ->will($this->returnValue($_table)); - - $dbi->expects($this->once()) - ->method('query') - ->with('SELECT', DatabaseInterface::CONNECT_USER, DatabaseInterface::QUERY_UNBUFFERED) - ->will($this->returnValue(true)); - - $dbi->expects($this->once()) - ->method('numFields') - ->with(true) - ->will($this->returnValue(3)); - - $dbi->expects($this->at(3)) - ->method('fieldName') - ->will($this->returnValue('fName1')); - - $dbi->expects($this->at(4)) - ->method('fieldName') - ->will($this->returnValue('fNa"me2')); - - $dbi->expects($this->at(5)) - ->method('fieldName') - ->will($this->returnValue('fNa\\me3')); - - $dbi->expects($this->at(6)) - ->method('fetchRow') - ->with(true) - ->will($this->returnValue([null, ''])); - - $GLOBALS['dbi'] = $dbi; - ob_start(); $this->assertTrue( $this->object->exportData( - 'db', - 'taassertIsString($result); - - $this->assertStringContainsString( - '', - $result - ); - - $this->assertStringContainsString( - '', - $result - ); - - $this->assertStringContainsString( - 'NULL', - $result - ); - - $this->assertStringContainsString( - '<a>' . - '', - $result - ); - - $this->assertStringContainsString( - 'NULL', - $result - ); - - $this->assertStringContainsString( - '
', + $this->assertEquals( + ' ' . "\n" + . ' ' . "\n" + . ' 1' . "\n" + . ' abcd' . "\n" + . ' 2011-01-20 02:00:02' . "\n" + . '
' . "\n" + . ' ' . "\n" + . ' 2' . "\n" + . ' foo' . "\n" + . ' 2010-01-20 02:00:02' . "\n" + . '
' . "\n" + . ' ' . "\n" + . ' 3' . "\n" + . ' Abcd' . "\n" + . ' 2012-01-20 02:00:02' . "\n" + . '
' . "\n", $result ); } diff --git a/test/classes/Stubs/DbiDummy.php b/test/classes/Stubs/DbiDummy.php index d18c77e0064c..2adcb248d418 100644 --- a/test/classes/Stubs/DbiDummy.php +++ b/test/classes/Stubs/DbiDummy.php @@ -2195,6 +2195,11 @@ private function init(): void ['datetimefield', 'datetime', 'NO', '', 'NULL', ''], ], ], + [ + 'query' => 'SHOW TABLE STATUS FROM `test_db` WHERE `Name` LIKE \'test\_table%\'', + 'columns' => ['Name', 'Engine', 'Rows'], + 'result' => [['test_table', 'InnoDB', '3']], + ], [ 'query' => 'SELECT * FROM `test_db`.`test_table`;', 'columns' => ['id', 'name', 'datetimefield'],