FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Fossology\Lib\Application\LicenseCsvImportTest Class Reference

Test for LicenseCsvImport. More...

Inheritance diagram for Fossology\Lib\Application\LicenseCsvImportTest:
Inheritance graph
Collaboration diagram for Fossology\Lib\Application\LicenseCsvImportTest:
Collaboration graph

Public Member Functions

 testGetKeyFromShortname ()
 Test for LicenseCsvImport::getKeyFromShortname() More...
 
 testGetKeyFromMd5 ()
 Test for LicenseCsvImport::getKeyFromMd5() More...
 
 testHandleCsvLicense ()
 Test for LicenseCsvImport::handleCsvLicense() More...
 
 testHandleHeadCsv ()
 Test for LicenseCsvImport::handleHeadCsv() More...
 
 testHandleHeadCsv_missingMandidatoryKey ()
 Test for LicenseCsvImport::handleHeadCsv() More...
 
 testSetDelimiter ()
 Test for LicenseCsvImport::setDelimiter() More...
 
 testSetEnclosure ()
 Test for LicenseCsvImport::setEnclosure() More...
 
 testHandleCsv ()
 Test for LicenseCsvImport::handleCsv() More...
 
 testHandleFileIfFileNotExists ()
 Test for LicenseCsvImport::handleFile() (non-existing file) More...
 
 testHandleFileIfFileIsNotParsable ()
 Test for LicenseCsvImport::handleFile() (non-csv file) More...
 
 testHandleFile ()
 Test for LicenseCsvImport::handleFile() (csv file with header) More...
 

Protected Member Functions

 setUp ()
 One time setup for test. More...
 
 tearDown ()
 Close mockery. More...
 

Private Member Functions

 createCandidateTable ($dbManager)
 
 addLicenseInsertToDbManager (&$dbManager, $row, $return, $table="license_ref")
 

Detailed Description

Test for LicenseCsvImport.

Definition at line 22 of file LicenseCsvImportTest.php.

Member Function Documentation

◆ addLicenseInsertToDbManager()

Fossology\Lib\Application\LicenseCsvImportTest::addLicenseInsertToDbManager ( $dbManager,
  $row,
  $return,
  $table = "license_ref" 
)
private

Add a new mockery handler for new license insertion in DB

Parameters
DbManager$dbManagerThe mock object of DbManager
array$rowThe associated array
mixed$returnThe value which should be returned
string$tableThe table where new data should go

Definition at line 729 of file LicenseCsvImportTest.php.

◆ createCandidateTable()

Fossology\Lib\Application\LicenseCsvImportTest::createCandidateTable (   $dbManager)
private

Create candidate license table

Parameters
DbManager$dbManager

Definition at line 714 of file LicenseCsvImportTest.php.

◆ setUp()

Fossology\Lib\Application\LicenseCsvImportTest::setUp ( )
protected

One time setup for test.

See also
PHPUnit::Framework::TestCase::setUp()

Definition at line 28 of file LicenseCsvImportTest.php.

◆ tearDown()

Fossology\Lib\Application\LicenseCsvImportTest::tearDown ( )
protected

Close mockery.

See also
PHPUnit::Framework::TestCase::tearDown()

Definition at line 37 of file LicenseCsvImportTest.php.

◆ testGetKeyFromMd5()

Fossology\Lib\Application\LicenseCsvImportTest::testGetKeyFromMd5 ( )

Test for LicenseCsvImport::getKeyFromMd5()

Test:
  1. Create test DB and insert a license in license_ref.
  2. Call LicenseCsvImport::getKeyFromMd5() on a known license.
  3. Check if the id matches.
  4. Call LicenseCsvImport::getKeyFromMd5() on an unknown license.
  5. Check if the return value is false.

Definition at line 97 of file LicenseCsvImportTest.php.

◆ testGetKeyFromShortname()

Fossology\Lib\Application\LicenseCsvImportTest::testGetKeyFromShortname ( )

Test for LicenseCsvImport::getKeyFromShortname()

Test:
  1. Create test DB and insert a license in license_ref.
  2. Call LicenseCsvImport::getKeyFromShortname() on a known license.
  3. Check if the id matches.
  4. Call LicenseCsvImport::getKeyFromShortname() on an unknown license.
  5. Check if the return value is false.

Definition at line 52 of file LicenseCsvImportTest.php.

◆ testHandleCsv()

Fossology\Lib\Application\LicenseCsvImportTest::testHandleCsv ( )

Test for LicenseCsvImport::handleCsv()

Test:
  1. Call LicenseCsvImport::handleCsv() for first time. headrow must be set.
  2. Call LicenseCsvImport::handleCsv() with sample data.
  3. Check if it is imported in nkMap

Definition at line 525 of file LicenseCsvImportTest.php.

◆ testHandleCsvLicense()

Fossology\Lib\Application\LicenseCsvImportTest::testHandleCsvLicense ( )

Test for LicenseCsvImport::handleCsvLicense()

Test:
  1. Mock DB manager object.
  2. Create object of LicenseCsvImport and initialize nkMap.
  3. Call several handle calls and check the log messages.

Definition at line 129 of file LicenseCsvImportTest.php.

◆ testHandleFile()

Fossology\Lib\Application\LicenseCsvImportTest::testHandleFile ( )

Test for LicenseCsvImport::handleFile() (csv file with header)

Test:
  1. Create an empty CSV file and write a valid header.
  2. Call LicenseCsvImport::handleFile().
  3. Function must return message starting with head okay.

Definition at line 605 of file LicenseCsvImportTest.php.

◆ testHandleFileIfFileIsNotParsable()

Fossology\Lib\Application\LicenseCsvImportTest::testHandleFileIfFileIsNotParsable ( )

Test for LicenseCsvImport::handleFile() (non-csv file)

Test:
  1. Call LicenseCsvImport::handleFile() on non-csv file
  2. Function must return Error while parsing file

Definition at line 589 of file LicenseCsvImportTest.php.

◆ testHandleFileIfFileNotExists()

Fossology\Lib\Application\LicenseCsvImportTest::testHandleFileIfFileNotExists ( )

Test for LicenseCsvImport::handleFile() (non-existing file)

Test:
  1. Call LicenseCsvImport::handleFile() on non-existing file
  2. Function must return Internal error

Definition at line 574 of file LicenseCsvImportTest.php.

◆ testHandleHeadCsv()

Fossology\Lib\Application\LicenseCsvImportTest::testHandleHeadCsv ( )

Test for LicenseCsvImport::handleHeadCsv()

Test:
  1. Initialize LicenseCsvImport.
  2. Call LicenseCsvImport::handleHeadCsv() on actual header names.
  3. Check if the header returned have required keys.
  4. Call LicenseCsvImport::handleHeadCsv() on alias header names.
  5. Check if the header returned have required keys.

Definition at line 427 of file LicenseCsvImportTest.php.

◆ testHandleHeadCsv_missingMandidatoryKey()

Fossology\Lib\Application\LicenseCsvImportTest::testHandleHeadCsv_missingMandidatoryKey ( )

Test for LicenseCsvImport::handleHeadCsv()

Test:
  1. Initialize LicenseCsvImport.
  2. Call LicenseCsvImport::handleHeadCsv() on missing header names.
  3. Function must throw an Exception.

Definition at line 465 of file LicenseCsvImportTest.php.

◆ testSetDelimiter()

Fossology\Lib\Application\LicenseCsvImportTest::testSetDelimiter ( )

Test for LicenseCsvImport::setDelimiter()

Test:
  1. Initialize LicenseCsvImport.
  2. Set a new delimiter using LicenseCsvImport::setDelimiter().
  3. Check if the delimiter is changed.
  4. Set a new delimiter using LicenseCsvImport::setDelimiter().
  5. Check if the delimiter is changed with only the first character passed.

Definition at line 483 of file LicenseCsvImportTest.php.

◆ testSetEnclosure()

Fossology\Lib\Application\LicenseCsvImportTest::testSetEnclosure ( )

Test for LicenseCsvImport::setEnclosure()

Test:
  1. Initialize LicenseCsvImport.
  2. Set a new enclosure using LicenseCsvImport::setEnclosure().
  3. Check if the enclosure is changed.
  4. Set a new enclosure using LicenseCsvImport::setEnclosure().
  5. Check if the enclosure is changed with only the first character passed.

Definition at line 505 of file LicenseCsvImportTest.php.


The documentation for this class was generated from the following file: