FOSSology  4.7.1
Open Source License Compliance by Open Source Software
Fossology\Lib\Application\CustomTextImportTest Class Reference

Unit tests for CustomTextImport — covering the C2 fix and import logic (alias mapping, duplicate detection, parseBoolean, normalizeBulkExportValues, associateLicenses exact-name lookup). More...

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

Public Member Functions

 testAssociateLicensesLooksUpSpdxNameDirectly ()
 
 testAssociateLicensesLooksUpOrLaterNameDirectly ()
 
 testAssociateLicensesTrimsWhitespace ()
 
 testAutoCreatesUnknownValidLicense ()
 
 testAssociateLicensesHandlesCommaSeparatedList ()
 
 testImportPhrasesSkipsDuplicateText ()
 
 testImportPhraseRejectsEmptyText ()
 
 testMapHeadersMapsCapitalisedNames ()
 
 testMapHeadersMapsLowerCaseNames ()
 
 testParseBoolean ($input, bool $expected)
 
 parseBooleanProvider ()
 
 testNormalizeBulkExportValuesPipeAcknowledgement ()
 
 testNormalizeBulkExportValuesArrayAcknowledgement ()
 
 testNormalizeBulkExportValuesRestoresNewlines ()
 
 testImportJsonDataReturnsCountMessage ()
 
 testImportJsonDataSkipsRowsWithoutText ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Private Member Functions

 makeLicense (int $id)
 

Private Attributes

 $dbManager
 
 $userDao
 
 $licenseDao
 
 $importer
 

Detailed Description

Unit tests for CustomTextImport — covering the C2 fix and import logic (alias mapping, duplicate detection, parseBoolean, normalizeBulkExportValues, associateLicenses exact-name lookup).

Definition at line 25 of file CustomTextImportTest.php.

Member Function Documentation

◆ makeLicense()

Fossology\Lib\Application\CustomTextImportTest::makeLicense ( int  $id)
private

Create a minimal License mock with getId() returning $id.

Definition at line 57 of file CustomTextImportTest.php.

◆ testAssociateLicensesHandlesCommaSeparatedList()

Fossology\Lib\Application\CustomTextImportTest::testAssociateLicensesHandlesCommaSeparatedList ( )
Test:
Comma-separated license list is split and each name looked up independently.

Definition at line 187 of file CustomTextImportTest.php.

◆ testAssociateLicensesLooksUpOrLaterNameDirectly()

Fossology\Lib\Application\CustomTextImportTest::testAssociateLicensesLooksUpOrLaterNameDirectly ( )
Test:
GPL-2.0-or-later must be looked up by its exact name, not mapped to GPL-2.0.

Definition at line 105 of file CustomTextImportTest.php.

◆ testAssociateLicensesLooksUpSpdxNameDirectly()

Fossology\Lib\Application\CustomTextImportTest::testAssociateLicensesLooksUpSpdxNameDirectly ( )
Test:
Regression for C2: GPL-2.0-only must be looked up as-is (not mangled to GPL-2.0). Before the fix, normalizeLicenseName would convert "GPL-2.0-only" to "GPL-2.0", causing the DB lookup to fail and a junk license to be auto-created.

Definition at line 72 of file CustomTextImportTest.php.

◆ testAssociateLicensesTrimsWhitespace()

Fossology\Lib\Application\CustomTextImportTest::testAssociateLicensesTrimsWhitespace ( )
Test:
License name with surrounding whitespace is trimmed before lookup.

Definition at line 133 of file CustomTextImportTest.php.

◆ testAutoCreatesUnknownValidLicense()

Fossology\Lib\Application\CustomTextImportTest::testAutoCreatesUnknownValidLicense ( )
Test:
Unknown license that passes isValidLicenseShortname → auto-created exactly once.

Definition at line 158 of file CustomTextImportTest.php.

◆ testImportJsonDataReturnsCountMessage()

Fossology\Lib\Application\CustomTextImportTest::testImportJsonDataReturnsCountMessage ( )
Test:
importJsonData returns a count message when given valid phrase data.

Definition at line 401 of file CustomTextImportTest.php.

◆ testImportJsonDataSkipsRowsWithoutText()

Fossology\Lib\Application\CustomTextImportTest::testImportJsonDataSkipsRowsWithoutText ( )
Test:
importJsonData skips rows with no text and counts only successful ones.

Definition at line 423 of file CustomTextImportTest.php.

◆ testImportPhraseRejectsEmptyText()

Fossology\Lib\Application\CustomTextImportTest::testImportPhraseRejectsEmptyText ( )
Test:
Empty text → rejected immediately with "Text is required".

Definition at line 239 of file CustomTextImportTest.php.

◆ testImportPhrasesSkipsDuplicateText()

Fossology\Lib\Application\CustomTextImportTest::testImportPhrasesSkipsDuplicateText ( )
Test:
Importing a phrase whose text_md5 is already in the DB → reported as duplicate, not inserted.

Definition at line 214 of file CustomTextImportTest.php.

◆ testMapHeadersMapsCapitalisedNames()

Fossology\Lib\Application\CustomTextImportTest::testMapHeadersMapsCapitalisedNames ( )
Test:
mapHeaders maps capitalised CSV header names to standard internal names.

Definition at line 257 of file CustomTextImportTest.php.

◆ testMapHeadersMapsLowerCaseNames()

Fossology\Lib\Application\CustomTextImportTest::testMapHeadersMapsLowerCaseNames ( )
Test:
mapHeaders maps lower-case JSON export names.

Definition at line 286 of file CustomTextImportTest.php.

◆ testNormalizeBulkExportValuesArrayAcknowledgement()

Fossology\Lib\Application\CustomTextImportTest::testNormalizeBulkExportValuesArrayAcknowledgement ( )
Test:
Array acknowledgement from JSON export is joined with "; ".

Definition at line 365 of file CustomTextImportTest.php.

◆ testNormalizeBulkExportValuesPipeAcknowledgement()

Fossology\Lib\Application\CustomTextImportTest::testNormalizeBulkExportValuesPipeAcknowledgement ( )
Test:
Pipe-separated acknowledgement from bulk CSV export is joined with "; ".

Definition at line 348 of file CustomTextImportTest.php.

◆ testNormalizeBulkExportValuesRestoresNewlines()

Fossology\Lib\Application\CustomTextImportTest::testNormalizeBulkExportValuesRestoresNewlines ( )
Test:
Literal
escape sequences in text are restored to real newlines.

Definition at line 382 of file CustomTextImportTest.php.

◆ testParseBoolean()

Fossology\Lib\Application\CustomTextImportTest::testParseBoolean (   $input,
bool  $expected 
)
Test:
parseBoolean accepts common truthy/falsy string representations.

@dataProvider parseBooleanProvider

Definition at line 313 of file CustomTextImportTest.php.


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