Skip to content

Commit

Permalink
feat: ApplicationLicenceList ByOrganisation now uses OrganisationOpti…
Browse files Browse the repository at this point in the history
…onal (#30)

* feat: Msg ApplicationLicenceList ByOrganisation now uses OrganisationOptional

* chore: added unit test for query

* fix: Fixed existing unit test using incorrect property
  • Loading branch information
jerotire authored Feb 6, 2024
1 parent f94175e commit 6fa893a
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Query/Messaging/ApplicationLicenceList/ByOrganisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dvsa\Olcs\Transfer\Query\Messaging\ApplicationLicenceList;

use Dvsa\Olcs\Transfer\FieldType\Traits\Organisation;
use Dvsa\Olcs\Transfer\FieldType\Traits\OrganisationOptional;
use Dvsa\Olcs\Transfer\Query\AbstractQuery;
use Dvsa\Olcs\Transfer\Util\Annotation as Transfer;

Expand All @@ -11,5 +11,5 @@
*/
final class ByOrganisation extends AbstractQuery
{
use Organisation;
use OrganisationOptional;
}
104 changes: 104 additions & 0 deletions test/Query/Messaging/ApplicationLicenceList/ByOrganisationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

declare(strict_types=1);

namespace Dvsa\OlcsTest\Transfer\Query\Messaging\ApplicationLicenceList;

use Dvsa\Olcs\Transfer\Query\Messaging\ApplicationLicenceList\ByOrganisation;
use Dvsa\OlcsTest\Transfer\DtoWithoutOptionalFieldsTest;
use Dvsa\OlcsTest\Transfer\Query\QueryTest;
use Laminas\Stdlib\ArraySerializableInterface;

class ByOrganisationTest extends \PHPUnit\Framework\TestCase
{
use QueryTest, DtoWithoutOptionalFieldsTest {
DtoWithoutOptionalFieldsTest::testDefaultValues insteadof QueryTest;
}

/**
* Should return a new blank DTO on which to run tests
*
* @return ArraySerializableInterface
*/
protected function createBlankDto()
{
return new ByOrganisation();
}

/**
* Should return an array of valid field values (i.e. those which should pass validation)
*
* for example:
*
* return [
* 'fieldName' => [
* 'good-value-1',
* 'good-value-2',
* ],
* 'anotherFieldName' => ['good-value'],
* ];
*
* @return array
*/
protected function getValidFieldValues()
{
return [
'organisation' => [
'1',
null,
],
];
}

/**
* Should return an array of invalid field values (i.e. those which should fail validation)
*
* for example:
*
* return [
* 'fieldName' => [
* 'bad-value-1',
* 'bad-value-2',
* ],
* 'anotherFieldName' => ['bad-value'],
* ];
*
* @return array
*/
protected function getInvalidFieldValues()
{
$invalidNumbers = [
0,
];

return [
'organisation' => $invalidNumbers,
];
}

/**
* Should return an array of expected transformations which input filters should apply to fields
*
* for example:
*
* return [
* 'fieldWhichGetsTrimmed' => [[' string ', 'string']],
* 'fieldWhichFiltersOutNonNumericDigits => [
* ['a1b2c3', '123'],
* [99, '99'],
* ],
* ];
*
* Tests expect the function 'getFoo' to exist for the function 'foo'.
*
* This DOES NOT assert that the value gets validated. To do that @see DtoTest::getValidFieldValues
*
* @return array
*/
protected function getFilterTransformations()
{
return [
'organisation' => [[99, '99']],
];
}
}
2 changes: 1 addition & 1 deletion test/Query/Messaging/Conversations/ByOrganisationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function getInvalidFieldValues()
protected function getFilterTransformations()
{
return [
'ids' => [[99, '99']],
'organisation' => [[99, '99']],
'page' => [[99, '99']],
'limit' => [[99, '99']],
];
Expand Down

0 comments on commit 6fa893a

Please sign in to comment.