20 private $assertCountBefore;
26 protected function setUp() : void
28 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
37 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount() - $this->assertCountBefore);
48 $dbManager = M::mock(DbManager::class);
49 $dbManager->shouldReceive(
'getRows')->once()->withAnyArgs()->andReturn(array(
51 'rf_text' =>
"hello, world\nsecond line",
52 'rf_shortname' =>
'MIT',
55 'acknowledgement' =>
null,
61 $csv = $bulkTextExport->exportBulkText();
63 $handle = fopen(
'php://temp',
'r+');
64 fwrite($handle, $csv);
68 while (($row = fgetcsv($handle, 0,
',',
'"')) !==
false) {
73 $this->assertCount(2, $rows);
74 $this->assertSame(
"\xEF\xBB\xBFtext", $rows[0][0]);
75 $this->assertSame(
'hello, world\\nsecond line', $rows[1][0]);
76 $this->assertSame(
'MIT', $rows[1][1]);
77 $this->assertSame(2, substr_count($csv,
"\n"));
85 $dbManager = M::mock(DbManager::class);
88 $this->expectException(\InvalidArgumentException::class);
89 $bulkTextExport->setDelimiter(
'');
97 $dbManager = M::mock(DbManager::class);
100 $this->expectException(\InvalidArgumentException::class);
101 $bulkTextExport->setEnclosure(
',');
Test for class BulkTextExport.
setUp()
One time setup for test.
testExportBulkTextCsvEscapesDelimiterAndNewlineInText()
testSetDelimiterRejectsEmptyValue()
testSetEnclosureRejectsSameValueAsDelimiter()
Helper class to export license reference bulk data as CSV or JSON from the DB.
Utility functions for specific applications.