FOSSology  4.7.1
Open Source License Compliance by Open Source Software
Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest Class Reference

Unit tests for LicenseCompatibilityRuleController. More...

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

Public Member Functions

 testGetRulesV1 ()
 
 testGetRulesV2 ()
 
 testGetRulesWithPaginationAndSearch ()
 
 testGetRulesInvalidLimit ()
 
 testGetRulesZeroLimit ()
 
 testGetRulesNonNumericLimit ()
 
 testGetRulesZeroPage ()
 
 testGetRulesPageOutOfRange ()
 
 testGetRulesNotAdmin ()
 
 testCreateRule ()
 
 testCreateRuleWithV1FieldNames ()
 
 testCreateRuleWithoutComment ()
 
 testCreateRuleWithEmptyComment ()
 
 testCreateRuleWithoutLicenseAndType ()
 
 testCreateRuleWithUnknownLicense ()
 
 testCreateRuleWithUnknownLicenseType ()
 
 testCreateRuleFailure ()
 
 testUpdateRule ()
 
 testUpdateRuleResetLicense ()
 
 testUpdateRuleNotFound ()
 
 testUpdateRuleEmptyBody ()
 
 testUpdateRuleWithoutRuleValues ()
 
 testDeleteRule ()
 
 testDeleteRuleNotFound ()
 
 testDeleteRuleFailure ()
 
 testImportRules ()
 
 testImportRulesInvalidFile ()
 
 testExportRules ()
 
 testExportRulesNotFound ()
 
 testExportRulesNotAdmin ()
 

Protected Member Functions

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

Private Member Functions

 getResponseJson ($response)
 
 getRuleRow ($ruleId)
 
 createJsonRequest ($method, $body, $version=ApiVersion::V2)
 
 createGetRequest ($query="", $version=ApiVersion::V2)
 
 testGetRules ($version=ApiVersion::V2)
 

Private Attributes

 $assertCountBefore
 
 $dbHelper
 
 $dbManager
 
 $restHelper
 
 $compatibilityDao
 
 $licenseYamlPlugin
 
 $ruleController
 
 $streamFactory
 

Detailed Description

Unit tests for LicenseCompatibilityRuleController.

Definition at line 39 of file LicenseCompatibilityRuleControllerTest.php.

Member Function Documentation

◆ createGetRequest()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::createGetRequest (   $query = "",
  $version = ApiVersion::V2 
)
private

Create a GET request with the given query string

Parameters
string$queryQuery string of the request
int$versionAPI version
Returns
Request

Definition at line 191 of file LicenseCompatibilityRuleControllerTest.php.

◆ createJsonRequest()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::createJsonRequest (   $method,
  $body,
  $version = ApiVersion::V2 
)
private

Create a request with the given JSON body

Parameters
string$methodHTTP method
array$bodyBody to be sent as JSON
int$versionAPI version
Returns
Request

Definition at line 173 of file LicenseCompatibilityRuleControllerTest.php.

◆ getResponseJson()

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

Helper function to get JSON array from response

Parameters
ResponseHelper$response
Returns
array Decoded response

Definition at line 138 of file LicenseCompatibilityRuleControllerTest.php.

◆ getRuleRow()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::getRuleRow (   $ruleId)
private

Generate a rule row as returned by the DAO

Parameters
int$ruleIdId of the rule
Returns
array

Definition at line 150 of file LicenseCompatibilityRuleControllerTest.php.

◆ setUp()

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

Setup test objects.

See also
PHPUnit_Framework_TestCase::setUp()

Definition at line 93 of file LicenseCompatibilityRuleControllerTest.php.

◆ tearDown()

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

Remove test objects.

See also
PHPUnit_Framework_TestCase::tearDown()

Definition at line 125 of file LicenseCompatibilityRuleControllerTest.php.

◆ testCreateRule()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testCreateRule ( )
Test:
  1. Test LicenseCompatibilityRuleController::createRule() for a valid rule
  2. Check if response status is 201

Definition at line 372 of file LicenseCompatibilityRuleControllerTest.php.

◆ testCreateRuleFailure()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testCreateRuleFailure ( )
Test:
  1. Test LicenseCompatibilityRuleController::createRule() when the rule can not be inserted
  2. Check if HttpInternalServerErrorException is thrown

Definition at line 520 of file LicenseCompatibilityRuleControllerTest.php.

◆ testCreateRuleWithEmptyComment()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testCreateRuleWithEmptyComment ( )
Test:
  1. Test LicenseCompatibilityRuleController::createRule() with an empty description
  2. Check if HttpBadRequestException is thrown

Definition at line 447 of file LicenseCompatibilityRuleControllerTest.php.

◆ testCreateRuleWithoutComment()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testCreateRuleWithoutComment ( )
Test:
  1. Test LicenseCompatibilityRuleController::createRule() without a description
  2. Check if HttpBadRequestException is thrown

Definition at line 430 of file LicenseCompatibilityRuleControllerTest.php.

◆ testCreateRuleWithoutLicenseAndType()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testCreateRuleWithoutLicenseAndType ( )
Test:
  1. Test LicenseCompatibilityRuleController::createRule() without any license or license type
  2. Check if HttpBadRequestException is thrown

Definition at line 465 of file LicenseCompatibilityRuleControllerTest.php.

◆ testCreateRuleWithUnknownLicense()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testCreateRuleWithUnknownLicense ( )
Test:
  1. Test LicenseCompatibilityRuleController::createRule() with a license which does not exist
  2. Check if HttpBadRequestException is thrown

Definition at line 482 of file LicenseCompatibilityRuleControllerTest.php.

◆ testCreateRuleWithUnknownLicenseType()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testCreateRuleWithUnknownLicenseType ( )
Test:
  1. Test LicenseCompatibilityRuleController::createRule() with a license type which is not configured
  2. Check if HttpBadRequestException is thrown

Definition at line 502 of file LicenseCompatibilityRuleControllerTest.php.

◆ testCreateRuleWithV1FieldNames()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testCreateRuleWithV1FieldNames ( )
Test:
  1. Test LicenseCompatibilityRuleController::createRule() with the version 1 field names
  2. Check if response status is 201

Definition at line 405 of file LicenseCompatibilityRuleControllerTest.php.

◆ testDeleteRule()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testDeleteRule ( )
Test:
  1. Test LicenseCompatibilityRuleController::deleteRule() for a valid request
  2. Check if response status is 200

Definition at line 651 of file LicenseCompatibilityRuleControllerTest.php.

◆ testDeleteRuleFailure()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testDeleteRuleFailure ( )
Test:
  1. Test LicenseCompatibilityRuleController::deleteRule() when the rule can not be deleted
  2. Check if HttpInternalServerErrorException is thrown

Definition at line 694 of file LicenseCompatibilityRuleControllerTest.php.

◆ testDeleteRuleNotFound()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testDeleteRuleNotFound ( )
Test:
  1. Test LicenseCompatibilityRuleController::deleteRule() for a rule which does not exist
  2. Check if HttpNotFoundException is thrown

Definition at line 677 of file LicenseCompatibilityRuleControllerTest.php.

◆ testExportRules()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testExportRules ( )
Test:
  1. Test LicenseCompatibilityRuleController::exportRules() for all the rules
  2. Check if the YAML of the rules is returned

Definition at line 761 of file LicenseCompatibilityRuleControllerTest.php.

◆ testExportRulesNotAdmin()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testExportRulesNotAdmin ( )
Test:
  1. Test LicenseCompatibilityRuleController::exportRules() as a non-admin user
  2. Check if HttpForbiddenException is thrown

Definition at line 810 of file LicenseCompatibilityRuleControllerTest.php.

◆ testExportRulesNotFound()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testExportRulesNotFound ( )
Test:
  1. Test LicenseCompatibilityRuleController::exportRules() for a rule which does not exist
  2. Check if HttpNotFoundException is thrown

Definition at line 793 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRules()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRules (   $version = ApiVersion::V2)
private
Parameters
$version
Returns
void

Definition at line 224 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesInvalidLimit()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesInvalidLimit ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() with an invalid limit
  2. Check if HttpBadRequestException is thrown

Definition at line 281 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesNonNumericLimit()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesNonNumericLimit ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() with a limit which is not a number
  2. Check if HttpBadRequestException is thrown

Definition at line 311 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesNotAdmin()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesNotAdmin ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() as a non-admin user
  2. Check if HttpForbiddenException is thrown

Definition at line 358 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesPageOutOfRange()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesPageOutOfRange ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() with a page above the total pages
  2. Check if HttpBadRequestException is thrown

Definition at line 342 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesV1()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesV1 ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() for version 1
  2. Check if the rules are returned with the snake_case keys

Definition at line 205 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesV2()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesV2 ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() for version 2
  2. Check if the rules are returned with the camelCase keys

Definition at line 215 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesWithPaginationAndSearch()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesWithPaginationAndSearch ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() with pagination and a search term
  2. Check if the DAO is called with the translated offset and search term

Definition at line 255 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesZeroLimit()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesZeroLimit ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() with a zero limit
  2. Check if HttpBadRequestException is thrown instead of falling back to the default limit

Definition at line 296 of file LicenseCompatibilityRuleControllerTest.php.

◆ testGetRulesZeroPage()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testGetRulesZeroPage ( )
Test:
  1. Test LicenseCompatibilityRuleController::getRules() with a zero page
  2. Check if HttpBadRequestException is thrown

Definition at line 325 of file LicenseCompatibilityRuleControllerTest.php.

◆ testImportRules()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testImportRules ( )

@runInSeparateProcess @preserveGlobalState disabled

Test:
  1. Test LicenseCompatibilityRuleController::importRules() for a valid request
  2. Check if response status is 200

Definition at line 715 of file LicenseCompatibilityRuleControllerTest.php.

◆ testImportRulesInvalidFile()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testImportRulesInvalidFile ( )

@runInSeparateProcess @preserveGlobalState disabled

Test:
  1. Test LicenseCompatibilityRuleController::importRules() when the upload is rejected
  2. Check if HttpBadRequestException is thrown

Definition at line 743 of file LicenseCompatibilityRuleControllerTest.php.

◆ testUpdateRule()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testUpdateRule ( )
Test:
  1. Test LicenseCompatibilityRuleController::updateRule() for a valid request
  2. Check if response status is 200

Definition at line 539 of file LicenseCompatibilityRuleControllerTest.php.

◆ testUpdateRuleEmptyBody()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testUpdateRuleEmptyBody ( )
Test:
  1. Test LicenseCompatibilityRuleController::updateRule() with an empty request body
  2. Check if HttpBadRequestException is thrown

Definition at line 616 of file LicenseCompatibilityRuleControllerTest.php.

◆ testUpdateRuleNotFound()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testUpdateRuleNotFound ( )
Test:
  1. Test LicenseCompatibilityRuleController::updateRule() for a rule which does not exist
  2. Check if HttpNotFoundException is thrown

Definition at line 598 of file LicenseCompatibilityRuleControllerTest.php.

◆ testUpdateRuleResetLicense()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testUpdateRuleResetLicense ( )
Test:
  1. Test LicenseCompatibilityRuleController::updateRule() with the licenses reset to null
  2. Check if response status is 200

Definition at line 571 of file LicenseCompatibilityRuleControllerTest.php.

◆ testUpdateRuleWithoutRuleValues()

Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::testUpdateRuleWithoutRuleValues ( )
Test:
  1. Test LicenseCompatibilityRuleController::updateRule() with a body holding no rule value
  2. Check if HttpBadRequestException is thrown

Definition at line 633 of file LicenseCompatibilityRuleControllerTest.php.

Member Data Documentation

◆ $assertCountBefore

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

Assertions before running tests

Definition at line 45 of file LicenseCompatibilityRuleControllerTest.php.

◆ $compatibilityDao

CompatibilityDao Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::$compatibilityDao
private

CompatibilityDao mock

Definition at line 69 of file LicenseCompatibilityRuleControllerTest.php.

◆ $dbHelper

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

DbHelper mock

Definition at line 51 of file LicenseCompatibilityRuleControllerTest.php.

◆ $dbManager

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

DbManager mock

Definition at line 57 of file LicenseCompatibilityRuleControllerTest.php.

◆ $licenseYamlPlugin

M MockInterface Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::$licenseYamlPlugin
private

admin_license_from_yaml mock

Definition at line 75 of file LicenseCompatibilityRuleControllerTest.php.

◆ $restHelper

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

RestHelper mock

Definition at line 63 of file LicenseCompatibilityRuleControllerTest.php.

◆ $ruleController

LicenseCompatibilityRuleController Fossology\UI\Api\Test\Controllers\LicenseCompatibilityRuleControllerTest::$ruleController
private

LicenseCompatibilityRuleController object

Definition at line 81 of file LicenseCompatibilityRuleControllerTest.php.

◆ $streamFactory

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

Stream factory to create body streams.

Definition at line 87 of file LicenseCompatibilityRuleControllerTest.php.


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