FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Fossology\UI\Api\Test\Controllers\LicenseControllerTest Class Reference

Unit tests for LicenseController. More...

Inheritance diagram for Fossology\UI\Api\Test\Controllers\LicenseControllerTest:
Inheritance graph
Collaboration diagram for Fossology\UI\Api\Test\Controllers\LicenseControllerTest:
Collaboration graph

Public Member Functions

 testGetLicense ()
 
 testGetLicenseObligations ()
 
 testGetLicenseNotFound ()
 
 testGetAllLicense ()
 
 testGetAllLicenseBounds ()
 
 testGetAllLicenseFilters ()
 
 testCreateLicense ()
 
 testCreateLicenseNoShort ()
 
 testCreateLicenseNoAdmin ()
 
 testCreateDuplicateLicense ()
 
 testUpdateLicense ()
 
 testUpdateLicenseNonAdvisor ()
 
 testUpdateLicenseNonAdmin ()
 
 testImportLicense ()
 
 testDeleteAdminLicenseCandidateIsAdmin ()
 
 testDeleteAdminLicenseCandidateNotAdmin ()
 
 testDeleteAdminLicenseCandidateNotFound ()
 
 testGetCandidates ()
 
 testGetCandidatesNoAdmin ()
 

Protected Member Functions

 setUp ()
 Setup test objects. More...
 
 tearDown ()
 Remove test objects. More...
 

Private Member Functions

 getResponseJson ($response)
 
 getObligation ($id)
 
 getDaoObligation ($id)
 
 getLicense ($shortname, $obligations=false, $emptyObligation=true)
 
 getDaoLicense ($shortname)
 
 translateLicenseToDb ($licenses)
 

Private Attributes

 $assertCountBefore
 
 $userId
 
 $groupId
 
 $dbHelper
 
 $dbManager
 
 $restHelper
 
 $licenseController
 
 $licenseDao
 
 $userDao
 
 $adminLicenseAckDao
 
 $licenseStdCommentDao
 
 $adminLicensePlugin
 
 $streamFactory
 
 $licenseCandidatePlugin
 
 $auth
 

Detailed Description

Unit tests for LicenseController.

Definition at line 44 of file LicenseControllerTest.php.

Member Function Documentation

◆ getDaoLicense()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::getDaoLicense (   $shortname)
private

Helper function to generate licenses from LicenseDao

Parameters
string$shortname
Returns
\Fossology\Lib\Data\License

Definition at line 275 of file LicenseControllerTest.php.

◆ getDaoObligation()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::getDaoObligation (   $id)
private

Helper function to generate obligations for License Dao

Parameters
integer$id
Returns
Obligation

Definition at line 222 of file LicenseControllerTest.php.

◆ getLicense()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::getLicense (   $shortname,
  $obligations = false,
  $emptyObligation = true 
)
private

Helper function to generate licenses

Parameters
string$shortname
boolean$obligations
boolean$emptyObligation
Returns
License

Definition at line 244 of file LicenseControllerTest.php.

◆ getObligation()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::getObligation (   $id)
private

Helper function to generate obligations

Parameters
integer$id
Returns
Obligation

Definition at line 211 of file LicenseControllerTest.php.

◆ getResponseJson()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::getResponseJson (   $response)
private

Helper function to get JSON array from response

Parameters
Response$response
Returns
array Decoded response

Definition at line 200 of file LicenseControllerTest.php.

◆ setUp()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::setUp ( )
protected

Setup test objects.

See also
PHPUnit_Framework_TestCase::setUp()

Definition at line 141 of file LicenseControllerTest.php.

◆ tearDown()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::tearDown ( )
protected

Remove test objects.

See also
PHPUnit_Framework_TestCase::tearDown()

Definition at line 187 of file LicenseControllerTest.php.

◆ testCreateDuplicateLicense()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testCreateDuplicateLicense ( )
Test:
  1. Test for LicenseController::createLicense() to create new license
  2. Simulate duplicate license name
  3. Check if response is 409

Definition at line 628 of file LicenseControllerTest.php.

◆ testCreateLicense()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testCreateLicense ( )
Test:
  1. Test for LicenseController::createLicense() to create new license
  2. Check if response is 201

Definition at line 520 of file LicenseControllerTest.php.

◆ testCreateLicenseNoAdmin()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testCreateLicenseNoAdmin ( )
Test:
  1. Test for LicenseController::createLicense() to create new license
  2. Non admin user can't create main license
  3. Check if response is 403

Definition at line 603 of file LicenseControllerTest.php.

◆ testCreateLicenseNoShort()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testCreateLicenseNoShort ( )
Test:
  1. Test for LicenseController::createLicense() to create new license
  2. The request body is malformed
  3. Check if response is 400

Definition at line 577 of file LicenseControllerTest.php.

◆ testDeleteAdminLicenseCandidateIsAdmin()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testDeleteAdminLicenseCandidateIsAdmin ( )
Test:
  1. Test for LicenseController::deleteAdminLicenseCandidate() to delete license-candidate.
  2. User is admin
  3. License-candidate is does exist
  4. Check if response is 200
  5. Check if response-body matches

Definition at line 835 of file LicenseControllerTest.php.

◆ testDeleteAdminLicenseCandidateNotAdmin()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testDeleteAdminLicenseCandidateNotAdmin ( )
Test:
  1. Test for LicenseController::deleteAdminLicenseCandidate() to delete license-candidate.
  2. User is not-admin
  3. License-candidate is does exist
  4. Check if response is 400
  5. Check if response-body matches

Definition at line 859 of file LicenseControllerTest.php.

◆ testDeleteAdminLicenseCandidateNotFound()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testDeleteAdminLicenseCandidateNotFound ( )
Test:
  1. Test for LicenseController::deleteAdminLicenseCandidate() to delete license-candidate.
  2. User is admin
  3. License-candidate don't exist
  4. Check if response is 404
  5. Check if rseponse-body matches

Definition at line 877 of file LicenseControllerTest.php.

◆ testGetAllLicense()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testGetAllLicense ( )
Test:
  1. Test for LicenseController::getAllLicenses() to fetch all licenses
  2. Check if response is 200
  3. Check if pagination headers are set

Definition at line 403 of file LicenseControllerTest.php.

◆ testGetAllLicenseBounds()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testGetAllLicenseBounds ( )
Test:
  1. Test for LicenseController::getAllLicenses() to fetch all licenses
  2. The page requested is out of bounds
  3. Check if response is 400
  4. Check if pagination headers are set

Definition at line 446 of file LicenseControllerTest.php.

◆ testGetAllLicenseFilters()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testGetAllLicenseFilters ( )
Test:
  1. Test for LicenseController::getAllLicenses() with kind filter
  2. Check if proper parameters are passed to DbHelper

Definition at line 466 of file LicenseControllerTest.php.

◆ testGetCandidates()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testGetCandidates ( )
Test:
  1. Test for LicenseController::getCandidates()
  2. Check if status is 200
  3. Check if response-body matches

Definition at line 897 of file LicenseControllerTest.php.

◆ testGetCandidatesNoAdmin()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testGetCandidatesNoAdmin ( )
Test:
  1. Test for LicenseController::getCandidates() as a non-admin user
  2. Check if status is 403

Definition at line 916 of file LicenseControllerTest.php.

◆ testGetLicense()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testGetLicense ( )
Test:
  1. Test for LicenseController::getLicense() to fetch single license
  2. Check if response is 200

Definition at line 317 of file LicenseControllerTest.php.

◆ testGetLicenseNotFound()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testGetLicenseNotFound ( )
Test:
  1. Test for LicenseController::getLicense(), license not found
  2. Check if response is 404

Definition at line 380 of file LicenseControllerTest.php.

◆ testGetLicenseObligations()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testGetLicenseObligations ( )
Test:
  1. Test for LicenseController::getLicense() to fetch single license
  2. The license now has obligations
  3. Check if response is 200

Definition at line 349 of file LicenseControllerTest.php.

◆ testImportLicense()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testImportLicense ( )

@runInSeparateProcess @preserveGlobalState disabled

Test:
  1. Test for LicenseController::handleImportLicense()
  2. Check if response status is 200
  3. Check if response body is matches the expected response body

Definition at line 789 of file LicenseControllerTest.php.

◆ testUpdateLicense()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testUpdateLicense ( )
Test:
  1. Test for LicenseController::updateLicense() to edit a license
  2. Check if response is 200

Definition at line 661 of file LicenseControllerTest.php.

◆ testUpdateLicenseNonAdmin()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testUpdateLicenseNonAdmin ( )
Test:
  1. Test for LicenseController::updateLicense() to edit a license
  2. User is not admin
  3. Check if response is 403

Definition at line 749 of file LicenseControllerTest.php.

◆ testUpdateLicenseNonAdvisor()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::testUpdateLicenseNonAdvisor ( )
Test:
  1. Test for LicenseController::updateLicense() to edit a license
  2. User is not admin/advisor of the group
  3. Check if response is 403

Definition at line 713 of file LicenseControllerTest.php.

◆ translateLicenseToDb()

Fossology\UI\Api\Test\Controllers\LicenseControllerTest::translateLicenseToDb (   $licenses)
private

Helper function to translate License to DB array

Parameters
array$licenses
Returns
array

Definition at line 295 of file LicenseControllerTest.php.

Member Data Documentation

◆ $adminLicenseAckDao

LicenseAcknowledgementDao Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$adminLicenseAckDao
private

LicenseAcknowledgementDao mock

Definition at line 104 of file LicenseControllerTest.php.

◆ $adminLicensePlugin

M MockInterface Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$adminLicensePlugin
private

admin_license_from_csv mock

Definition at line 116 of file LicenseControllerTest.php.

◆ $assertCountBefore

integer Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$assertCountBefore
private

Assertions before running tests

Definition at line 50 of file LicenseControllerTest.php.

◆ $auth

Auth Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$auth
private

Auth mock

Definition at line 135 of file LicenseControllerTest.php.

◆ $dbHelper

DbHelper Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$dbHelper
private

DbHelper mock

Definition at line 68 of file LicenseControllerTest.php.

◆ $dbManager

DbManager Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$dbManager
private

Dbmanager mock

Definition at line 74 of file LicenseControllerTest.php.

◆ $groupId

integer Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$groupId
private

Group ID to mock

Definition at line 62 of file LicenseControllerTest.php.

◆ $licenseCandidatePlugin

M MockInterface Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$licenseCandidatePlugin
private

admin_license_candidate mock

Definition at line 128 of file LicenseControllerTest.php.

◆ $licenseController

LicenseController Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$licenseController
private

LicenseController mock

Definition at line 86 of file LicenseControllerTest.php.

◆ $licenseDao

LicenseDao Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$licenseDao
private

LicenseDao mock

Definition at line 92 of file LicenseControllerTest.php.

◆ $licenseStdCommentDao

LicenseStdCommentDao Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$licenseStdCommentDao
private

LicenseStdCommentDao mock

Definition at line 110 of file LicenseControllerTest.php.

◆ $restHelper

RestHelper Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$restHelper
private

RestHelper mock

Definition at line 80 of file LicenseControllerTest.php.

◆ $streamFactory

StreamFactory Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$streamFactory
private

Stream factory to create body streams.

Definition at line 122 of file LicenseControllerTest.php.

◆ $userDao

UserDao Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$userDao
private

UserDao mock

Definition at line 98 of file LicenseControllerTest.php.

◆ $userId

integer Fossology\UI\Api\Test\Controllers\LicenseControllerTest::$userId
private

User ID to mock

Definition at line 56 of file LicenseControllerTest.php.


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