/** * test xls export * * @return void * * @todo save and test xls file (with xls reader) * @todo check metadata * @todo add note/partner checks again? */ public function testExportXls() { $excelObj = $this->_instance->generate(); // output as csv $xlswriter = new PHPExcel_Writer_CSV($excelObj); $xlswriter->setSheetIndex(1); //$xlswriter->save('php://output'); $csvFilename = tempnam(sys_get_temp_dir(), 'csvtest'); $xlswriter->save($csvFilename); $this->assertTrue(file_exists($csvFilename)); $export = file_get_contents($csvFilename); $this->assertEquals(1, preg_match("/PHPUnit/", $export), 'no name'); $this->assertEquals(1, preg_match("/Description/", $export), 'no description'); $this->assertEquals(1, preg_match('/' . preg_quote(Tinebase_Core::getUser()->accountDisplayName) . '/', $export), 'no creator'); $this->assertEquals(1, preg_match('/open/', $export), 'no leadstate'); unlink($csvFilename); }
/** * test xls export * * @return void * * @todo save and test xls file (with xls reader) * @todo check metadata * @todo add note/partner checks again? */ public function testExportXls() { $excelObj = $this->_instance->generate(); // output as csv $xlswriter = new PHPExcel_Writer_CSV($excelObj); $xlswriter->setSheetIndex(1); //$xlswriter->save('php://output'); $csvFilename = tempnam(sys_get_temp_dir(), 'csvtest'); $xlswriter->save($csvFilename); //$noteString = Tinebase_Translation::getTranslation('Tinebase')->_('created') . ' ' . Tinebase_Translation::getTranslation('Tinebase')->_('by'); $this->assertTrue(file_exists($csvFilename)); $export = file_get_contents($csvFilename); $this->assertEquals(1, preg_match("/PHPUnit/", $export), 'no name'); $this->assertEquals(1, preg_match("/Description/", $export), 'no description'); $this->assertEquals(1, preg_match('/Admin Account, Tine 2.0/', $export), 'no creator'); $this->assertEquals(1, preg_match('/open/', $export), 'no leadstate'); //$this->assertEquals(1, preg_match('/Kneschke/', $export), 'no partner'); //$this->assertEquals(1, preg_match('/' . $noteString . '/', $export), 'no note'); unlink($csvFilename); }
/** * test xls export * * @return void * * @todo save and test xls file (with xls reader) * @todo check metadata * @todo add note/partner checks again? */ public function testExportXls() { // skip tests for php7 // PHP Fatal error: 'break' not in the 'loop' or 'switch' context in /usr/local/share/tine20.git/tine20/vendor/codeplex/phpexcel/PHPExcel/Calculation/Functions.php on line 574 if (PHP_VERSION_ID >= 70000) { $this->markTestSkipped('FIXME in php7'); } $translate = Tinebase_Translation::getTranslation('Crm'); $excelObj = $this->_instance->generate(); // output as csv $xlswriter = new PHPExcel_Writer_CSV($excelObj); $xlswriter->setSheetIndex(1); //$xlswriter->save('php://output'); $csvFilename = tempnam(sys_get_temp_dir(), 'csvtest'); $xlswriter->save($csvFilename); $this->assertTrue(file_exists($csvFilename)); $export = file_get_contents($csvFilename); $this->assertEquals(1, preg_match("/PHPUnit/", $export), 'no name'); $this->assertEquals(1, preg_match("/Description/", $export), 'no description'); $this->assertEquals(1, preg_match('/' . preg_quote(Tinebase_Core::getUser()->accountDisplayName) . '/', $export), 'no creator'); $this->assertEquals(1, preg_match('/' . $translate->_('open') . '/', $export), 'no leadstate'); unlink($csvFilename); }