FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
LicenseCsvImportTest.php
1 <?php
2 /*
3 Copyright (C) 2014-2015, Siemens AG
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 version 2 as published by the Free Software Foundation.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
20 
27 use Mockery as M;
28 
33 class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
34 {
39  protected function setUp()
40  {
41  $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
42  }
43 
48  protected function tearDown()
49  {
50  $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
51  M::close();
52  }
53 
63  public function testGetKeyFromShortname()
64  {
65  $testDb = new TestLiteDb();
66  $testDb->createPlainTables(array('license_ref'));
67  $shortname = 'licA';
68  $knownId = 101;
69  $knownGroup = 4;
70  /*** @var DbManager ***/
71  $dbManager = &$testDb->getDbManager();
72  $dbManager->insertTableRow('license_ref', array('rf_pk'=>$knownId,'rf_shortname'=>$shortname));
73  $this->createCandidateTable($dbManager);
74  $dbManager->insertTableRow('license_candidate', array(
75  'rf_pk' => $knownId + 2,
76  'rf_shortname' => "candidate-$shortname",
77  'group_fk' => $knownGroup
78  ));
79  $userDao = M::mock(UserDao::class);
80  $userDao->shouldReceive('getGroupIdByName')
81  ->with("fossy")
82  ->once()
83  ->andReturn(4);
84  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
85 
86  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'getKeyFromShortname', array($shortname)), equalTo($knownId));
87  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'getKeyFromShortname', array("no $shortname")), equalTo(false));
88  // Candidates
89  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
90  'getKeyFromShortname',
91  array("candidate-$shortname", "fossy")),
92  equalTo($knownId + 2));
93  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
94  'getKeyFromShortname',
95  array("candidate-$shortname")),
96  equalTo(false));
97  }
98 
108  public function testGetKeyFromMd5()
109  {
110  $licenseText = 'I am a strong license';
111  $knownId = 101;
112  $falseLicenseText = "I am a weak license";
113 
114  $dbManager = M::mock(DbManager::class);
115  $dbManager->shouldReceive('getSingleRow')
116  ->with('SELECT rf_pk FROM ONLY license_ref WHERE rf_md5=md5($1)',
117  array($licenseText))
118  ->once()
119  ->andReturn(array('rf_pk' => $knownId));
120  $dbManager->shouldReceive('getSingleRow')
121  ->with('SELECT rf_pk FROM ONLY license_ref WHERE rf_md5=md5($1)',
122  array($falseLicenseText))
123  ->andReturnNull();
124  $userDao = M::mock(UserDao::class);
125  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
126 
127  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
128  'getKeyFromMd5', array($licenseText)), equalTo($knownId));
129  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
130  'getKeyFromMd5', array($falseLicenseText)), equalTo(false));
131  }
132 
140  public function testHandleCsvLicense()
141  {
142  $dbManager = M::mock(DbManager::class);
143  $nkMap = array(
144  'licA' => 101,
145  'licB' => false,
146  'licC' => false,
147  'licE' => false,
148  'licF' => false,
149  'licG' => false,
150  'licH' => false,
151  'licZ' => 100,
152  'canLicAfossy' => 200,
153  'canLicBfossy' => false
154  );
155  $mdkMap = array(
156  md5('txA') => 101,
157  md5('txB') => false,
158  md5('txC') => false,
159  md5('txD') => 102,
160  md5('txE') => false,
161  md5('txF') => false,
162  md5('txG') => false,
163  md5('txH') => false,
164  md5('txZ') => 100,
165  md5('txCan') => 200,
166  md5('Text of candidate license') => false
167  );
168  $userDao = M::mock(UserDao::class);
169  $userDao->shouldReceive('getGroupIdByName')
170  ->with("fossy")
171  ->times(3)
172  ->andReturn(4);
173 
174  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
175  Reflectory::setObjectsProperty($licenseCsvImport, 'nkMap', $nkMap);
176  Reflectory::setObjectsProperty($licenseCsvImport, 'mdkMap', $mdkMap);
177 
178  $singleRowA = array(
179  'rf_shortname' => 'licA',
180  'rf_fullname' => 'licennnseA',
181  'rf_text' => 'someRandom',
182  'rf_md5' => md5('someRandom'),
183  'rf_detector_type' => 1,
184  'rf_url' => '',
185  'rf_notes' => '',
186  'rf_source' => '',
187  'rf_risk' => 4
188  );
189  $dbManager->shouldReceive('getSingleRow')
190  ->with(
191  'SELECT rf_shortname, rf_fullname, rf_text, rf_url, rf_notes, rf_source, rf_risk ' .
192  'FROM license_ref WHERE rf_pk = $1', array(101), anything())
193  ->once()
194  ->andReturn($singleRowA);
195 
196  // Test for licB insert
197  $dbManager->shouldReceive('insertTableRow')
198  ->withArgs(array(
199  'license_map', array(
200  'rf_fk' => 103, 'rf_parent' => 101, 'usage' => LicenseMap::CONCLUSION
201  )))
202  ->once();
203  $singleRowB = $singleRowA;
204  $singleRowB["rf_shortname"] = "licB";
205  $singleRowB["rf_fullname"] = "liceB";
206  $singleRowB["rf_text"] = "txB";
207  $singleRowB["rf_md5"] = md5("txB");
208  $singleRowB["rf_risk"] = 0;
209  $this->addLicenseInsertToDbManager($dbManager, $singleRowB, 103);
210  $returnB = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
211  'handleCsvLicense', array(array(
212  'shortname' => 'licB',
213  'fullname' => 'liceB',
214  'text' => 'txB',
215  'url' => '',
216  'notes' => '',
217  'source' => '',
218  'risk' => 0,
219  'parent_shortname' => 'licA',
220  'report_shortname' => null,
221  'group' => null
222  )));
223  assertThat($returnB, is("Inserted 'licB' in DB with conclusion 'licA'"));
224 
225  // Test for licF insert
226  $singleRowF = $singleRowA;
227  $singleRowF["rf_shortname"] = "licF";
228  $singleRowF["rf_fullname"] = "liceF";
229  $singleRowF["rf_text"] = "txF";
230  $singleRowF["rf_md5"] = md5("txF");
231  $singleRowF["rf_risk"] = 1;
232  $this->addLicenseInsertToDbManager($dbManager, $singleRowF, 104);
233  $dbManager->shouldReceive('insertTableRow')
234  ->withArgs(array(
235  'license_map', array(
236  'rf_fk' => 104,
237  'rf_parent' => 100,
238  'usage' => LicenseMap::REPORT
239  )))
240  ->once();
241  $returnF = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
242  'handleCsvLicense', array(array(
243  'shortname' => 'licF',
244  'fullname' => 'liceF',
245  'text' => 'txF',
246  'url' => '',
247  'notes' => '',
248  'source' => '',
249  'risk' => 1,
250  'parent_shortname' => null,
251  'report_shortname' => 'licZ',
252  'group' => null
253  )));
254  assertThat($returnF, is("Inserted 'licF' in DB reporting 'licZ'"));
255 
256  // Test licC insert
257  $singleRowC = $singleRowA;
258  $singleRowC["rf_shortname"] = "licC";
259  $singleRowC["rf_fullname"] = "liceC";
260  $singleRowC["rf_text"] = "txC";
261  $singleRowC["rf_md5"] = md5("txC");
262  $singleRowC["rf_risk"] = 2;
263  $this->addLicenseInsertToDbManager($dbManager, $singleRowC, 105);
264  $returnC = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
265  'handleCsvLicense', array(array(
266  'shortname' => 'licC',
267  'fullname' => 'liceC',
268  'text' => 'txC',
269  'url' => '',
270  'notes' => '',
271  'source' => '',
272  'risk' => 2,
273  'parent_shortname' => null,
274  'report_shortname' => null,
275  'group' => null
276  )));
277  assertThat($returnC, is("Inserted 'licC' in DB"));
278 
279  // Test canlicC update
280  $canLicA = $singleRowA;
281  $canLicA["rf_shortname"] = "canLicA";
282  $canLicA["rf_fullname"] = "canLiceA";
283  $canLicA["rf_text"] = "txcan";
284  $canLicA["rf_risk"] = 0;
285  $canLicA["rf_group"] = 4;
286  $dbManager->shouldReceive('getSingleRow')
287  ->with(
288  'SELECT rf_shortname, rf_fullname, rf_text, rf_url, rf_notes, rf_source, rf_risk ' .
289  'FROM license_ref WHERE rf_pk = $1', array(200), anything())
290  ->once()
291  ->andReturn($canLicA);
292  $dbManager->shouldReceive('getSingleRow')
293  ->with(
294  "UPDATE license_candidate SET " .
295  "rf_fullname=$2,rf_text=$3,rf_md5=md5($3) WHERE rf_pk=$1;",
296  array(200, 'canDidateLicenseA', 'Text of candidate license'),
297  anything())
298  ->once();
299  $dbManager->shouldReceive('getSingleRow')
300  ->with(
301  'SELECT rf_parent FROM license_map WHERE rf_fk = $1 AND usage = $2;',
302  anyof(array(200, LicenseMap::CONCLUSION), array(200, LicenseMap::REPORT)),
303  anything())
304  ->twice()
305  ->andReturn(array('rf_parent' => null));
306  $returnC = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
307  'handleCsvLicense', array(array(
308  'shortname' => 'canLicA',
309  'fullname' => 'canDidateLicenseA',
310  'text' => 'Text of candidate license',
311  'url' => '', 'notes' => '', 'source' => '', 'risk' => 0,
312  'parent_shortname' => null, 'report_shortname' => null,
313  'group' => 'fossy'
314  )));
315  assertThat($returnC, is(
316  "License 'canLicA' already exists in DB (id = 200)" .
317  ", updated fullname, updated text"
318  ));
319 
320  // Test licA update
321  $dbManager->shouldReceive('getSingleRow')
322  ->with(
323  "UPDATE license_ref SET " .
324  "rf_fullname=$2,rf_text=$3,rf_md5=md5($3),rf_risk=$4 WHERE rf_pk=$1;",
325  array(101, 'liceB', 'txA', 2), anything())
326  ->once();
327  $dbManager->shouldReceive('getSingleRow')
328  ->with(
329  'SELECT rf_parent FROM license_map WHERE rf_fk = $1 AND usage = $2;',
330  anyof(array(101, LicenseMap::CONCLUSION), array(101, LicenseMap::REPORT)),
331  anything())
332  ->twice()
333  ->andReturn(array('rf_parent' => null));
334  $returnA = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
335  'handleCsvLicense', array(array(
336  'shortname' => 'licA',
337  'fullname' => 'liceB',
338  'text' => 'txA',
339  'url' => '',
340  'notes' => '',
341  'source' => '',
342  'risk' => 2,
343  'parent_shortname' => null,
344  'report_shortname' => null,
345  'group' => null
346  )));
347  assertThat($returnA, is(
348  "License 'licA' already exists in DB (id = 101)" .
349  ", updated fullname, updated text, updated the risk level"));
350 
351  // Test licE md5 collision
352  $returnE = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
353  'handleCsvLicense', array(array(
354  'shortname' => 'licE',
355  'fullname' => 'liceE',
356  'text' => 'txD',
357  'url' => '',
358  'notes' => '',
359  'source' => '',
360  'risk' => false,
361  'parent_shortname' => null,
362  'report_shortname' => null,
363  'group' => null
364  )));
365  assertThat($returnE, is(
366  "Error: MD5 checksum of 'licE' collides with license id=102"));
367 
368  // Test licG md5 collision
369  $returnG = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
370  'handleCsvLicense', array(array(
371  'shortname' => 'licG',
372  'fullname' => 'liceG',
373  'text' => 'txD',
374  'url' => '',
375  'notes' => '',
376  'source' => '_G_go_G_',
377  'parent_shortname' => null,
378  'report_shortname' => null,
379  'risk' => false,
380  'group' => null
381  )));
382  assertThat($returnG, is(
383  "Error: MD5 checksum of 'licG' collides with license id=102"));
384 
385  // Test canlicB insert
386  $canlicB = $singleRowA;
387  $canlicB["rf_shortname"] = "canLicB";
388  $canlicB["rf_fullname"] = "canLiceB";
389  $canlicB["rf_text"] = "txCan";
390  $canlicB["rf_md5"] = md5("txCan");
391  $canlicB["rf_risk"] = 2;
392  $canlicB["group_fk"] = 4;
393  $canlicB["marydone"] = 't';
394  $this->addLicenseInsertToDbManager($dbManager, $canlicB, 201,
395  "license_candidate");
396  $dbManager->shouldReceive('booleanToDb')
397  ->with(true)
398  ->once()
399  ->andReturn('t');
400  $returnC = Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
401  'handleCsvLicense', array(array(
402  'shortname' => 'canLicB',
403  'fullname' => 'canLiceB',
404  'text' => 'txCan',
405  'url' => '',
406  'notes' => '',
407  'source' => '',
408  'risk' => 2,
409  'parent_shortname' => null,
410  'report_shortname' => null,
411  'group' => 'fossy'
412  )));
413  assertThat($returnC, is("Inserted 'canLicB' in DB" .
414  " as candidate license under group fossy"));
415  }
416 
427  public function testHandleHeadCsv()
428  {
429  $dbManager = M::mock(DbManager::class);
430  $userDao = M::mock(UserDao::class);
431  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
432 
433  assertThat(
434  Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleHeadCsv',
435  array(array(
436  'shortname', 'foo', 'text', 'fullname', 'notes', 'bar'
437  ))),
438  is(array(
439  'shortname' => 0, 'fullname' => 3, 'text' => 2,
440  'parent_shortname' => false, 'report_shortname' => false,
441  'url' => false, 'notes' => 4, 'source' => false, 'risk' => 0,
442  'group' => false
443  )));
444 
445  assertThat(
446  Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleHeadCsv',
447  array(array(
448  'Short Name', 'URL', 'text', 'fullname', 'notes', 'Foreign ID',
449  'License group'
450  ))),
451  is(array(
452  'shortname' => 0, 'fullname' => 3, 'text' => 2,
453  'parent_shortname' => false, 'report_shortname' => false, 'url' => 1,
454  'notes' => 4, 'source' => 5, 'risk' => false, 'group' => 6
455  )));
456  }
457 
467  {
468  $dbManager = M::mock(DbManager::class);
469  $userDao = M::mock(UserDao::class);
470  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
471  Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleHeadCsv',array(array('shortname','foo','text')));
472  }
473 
483  public function testSetDelimiter()
484  {
485  $dbManager = M::mock(DbManager::class);
486  $userDao = M::mock(UserDao::class);
487  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
488 
489  $licenseCsvImport->setDelimiter('|');
490  assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'delimiter'),is('|'));
491 
492  $licenseCsvImport->setDelimiter('<>');
493  assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'delimiter'),is('<'));
494  }
495 
505  public function testSetEnclosure()
506  {
507  $dbManager = M::mock(DbManager::class);
508  $userDao = M::mock(UserDao::class);
509  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
510 
511  $licenseCsvImport->setEnclosure('|');
512  assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'enclosure') ,is('|'));
513 
514  $licenseCsvImport->setEnclosure('<>');
515  assertThat(Reflectory::getObjectsProperty($licenseCsvImport,'enclosure'),is('<'));
516  }
517 
525  public function testHandleCsv()
526  {
527  $dbManager = M::mock(DbManager::class);
528  $userDao = M::mock(UserDao::class);
529  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
530 
531  Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleCsv',
532  array(array('shortname', 'foo', 'text', 'fullname', 'notes')));
533  assertThat(Reflectory::getObjectsProperty($licenseCsvImport, 'headrow'),
534  is(notNullValue()));
535 
536  $dbManager->shouldReceive('getSingleRow')
537  ->with(
538  'SELECT rf_shortname,rf_source,rf_pk,rf_risk FROM license_ref WHERE rf_md5=md5($1)',
539  anything())
540  ->andReturn(false);
541  $licenseRow = array(
542  "rf_shortname" => "licA",
543  "rf_fullname" => "liceA",
544  "rf_text" => "txA",
545  "rf_md5" => md5("txA"),
546  "rf_detector_type" => 1,
547  "rf_url" => '',
548  "rf_notes" => 'noteA',
549  "rf_source" => '',
550  "rf_risk" => 0
551  );
552  $this->addLicenseInsertToDbManager($dbManager, $licenseRow, 101);
553  Reflectory::setObjectsProperty($licenseCsvImport, 'nkMap', array(
554  'licA' => false
555  ));
556  Reflectory::setObjectsProperty($licenseCsvImport, 'mdkMap', array(
557  md5('txA') => false
558  ));
559  Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleCsv',
560  array(array('licA', 'bar', 'txA', 'liceA', 'noteA')));
561  assertThat(Reflectory::getObjectsProperty($licenseCsvImport, 'nkMap'),
562  is(array('licA' => 101)));
563  assertThat(Reflectory::getObjectsProperty($licenseCsvImport, 'mdkMap'),
564  is(array(md5('txA') => 101)));
565  }
566 
574  {
575  $dbManager = M::mock(DbManager::class);
576  $userDao = M::mock(UserDao::class);
577  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
578  $msg = $licenseCsvImport->handleFile('/tmp/thisFileNameShouldNotExists');
579  assertThat($msg, is(equalTo(_('Internal error'))));
580  }
581 
589  {
590  $dbManager = M::mock(DbManager::class);
591  $userDao = M::mock(UserDao::class);
592  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
593  $msg = $licenseCsvImport->handleFile(__FILE__);
594  assertThat($msg, startsWith( _('Error while parsing file')));
595  }
596 
604  public function testHandleFile()
605  {
606  $dbManager = M::mock(DbManager::class);
607  $userDao = M::mock(UserDao::class);
608  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
609  $filename = tempnam("/tmp", "FOO");
610  $handle = fopen($filename, 'w');
611  fwrite($handle, "shortname,fullname,text");
612  fclose($handle);
613  $msg = $licenseCsvImport->handleFile($filename);
614  assertThat($msg, startsWith( _('head okay')));
615  unlink($filename);
616  }
617 
625  public function testSetMapTrue()
626  {
627  $testDb = new TestLiteDb();
628  $testDb->createPlainTables(array('license_ref', 'license_map'));
629  $licenseId = 101;
630  $parentId = 102;
631  $reportId = 103;
633  $dbManager = &$testDb->getDbManager();
634  $dbManager->insertTableRow('license_ref', array(
635  'rf_pk' => $licenseId,
636  'rf_shortname' => "Main License"
637  ));
638  $dbManager->insertTableRow('license_ref', array(
639  'rf_pk' => $parentId,
640  'rf_shortname' => "Parent License"
641  ));
642  $dbManager->insertTableRow('license_ref', array(
643  'rf_pk' => $reportId,
644  'rf_shortname' => "Reported License"
645  ));
646  $userDao = M::mock(UserDao::class);
647  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
648 
649  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
650  'setMap', array($parentId, $licenseId, LicenseMap::CONCLUSION)),
651  equalTo(true));
652  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
653  'setMap', array($reportId, $licenseId, LicenseMap::REPORT)),
654  equalTo(true));
655 
656  $sql = "SELECT rf_parent FROM license_map WHERE rf_fk = $1 AND usage = $2;";
657  $statement = __METHOD__ . ".getMap";
658  $row = $dbManager->getSingleRow($sql, array($licenseId,
659  LicenseMap::CONCLUSION), $statement);
660 
661  assertThat($row['rf_parent'], equalTo($parentId));
662  $row = $dbManager->getSingleRow($sql, array($licenseId,
663  LicenseMap::REPORT), $statement);
664  assertThat($row['rf_parent'], equalTo($reportId));
665  }
666 
675  public function testSetMapFalse()
676  {
677  $testDb = new TestLiteDb();
678  $testDb->createPlainTables(array('license_ref', 'license_map'));
679  $licenseId = 101;
680  $parentId = false;
681  $reportId = false;
683  $dbManager = &$testDb->getDbManager();
684  $dbManager->insertTableRow('license_ref', array(
685  'rf_pk' => $licenseId,
686  'rf_shortname' => "Main License"
687  ));
688  $userDao = M::mock(UserDao::class);
689  $licenseCsvImport = new LicenseCsvImport($dbManager, $userDao);
690 
691  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
692  'setMap', array($parentId, $licenseId, LicenseMap::CONCLUSION)),
693  equalTo(false));
694  assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,
695  'setMap', array($reportId, $licenseId, LicenseMap::REPORT)),
696  equalTo(false));
697 
698  $sql = "SELECT rf_parent FROM license_map WHERE rf_fk = $1 AND usage = $2;";
699  $statement = __METHOD__ . ".getMap";
700  $row = $dbManager->getSingleRow($sql, array($licenseId,
701  LicenseMap::CONCLUSION), $statement);
702 
703  assertThat($row, equalTo(false));
704  $row = $dbManager->getSingleRow($sql, array($licenseId,
705  LicenseMap::REPORT), $statement);
706  assertThat($row, equalTo(false));
707  }
708 
713  private function createCandidateTable($dbManager)
714  {
715  $sql = "CREATE TABLE license_candidate (" .
716  "rf_pk, rf_shortname, rf_fullname, rf_text, rf_md5, rf_url, rf_notes, " .
717  "marydone, rf_source, rf_risk, rf_detector_type, group_fk)";
718  $dbManager->queryOnce($sql);
719  }
720 
728  private function addLicenseInsertToDbManager(&$dbManager, $row, $return,
729  $table = "license_ref")
730  {
731  $dbManager->shouldReceive('insertTableRow')
732  ->with($table, $row, anything(), 'rf_pk')
733  ->once()
734  ->andReturn($return);
735  }
736 }
testHandleCsv()
Test for LicenseCsvImport::handleCsv()
testHandleFileIfFileNotExists()
Test for LicenseCsvImport::handleFile() (non-existing file)
addLicenseInsertToDbManager(&$dbManager, $row, $return, $table="license_ref")
testGetKeyFromMd5()
Test for LicenseCsvImport::getKeyFromMd5()
testHandleHeadCsv_missingMandidatoryKey()
Test for LicenseCsvImport::handleHeadCsv()
testHandleHeadCsv()
Test for LicenseCsvImport::handleHeadCsv()
testGetKeyFromShortname()
Test for LicenseCsvImport::getKeyFromShortname()
testHandleFileIfFileIsNotParsable()
Test for LicenseCsvImport::handleFile() (non-csv file)
testSetDelimiter()
Test for LicenseCsvImport::setDelimiter()
Utility functions for specific applications.
testHandleFile()
Test for LicenseCsvImport::handleFile() (csv file with header)
testHandleCsvLicense()
Test for LicenseCsvImport::handleCsvLicense()
testSetEnclosure()
Test for LicenseCsvImport::setEnclosure()