Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-kulhanek committed Aug 2, 2023
1 parent 0ec7da5 commit ff4eff3
Show file tree
Hide file tree
Showing 29 changed files with 167 additions and 165 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ jobs:
include:
- operating-system: "ubuntu-latest"
php-version: "8.1"
- operating-system: "ubuntu-latest"
php-version: "8.2"
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
Expand All @@ -44,10 +46,12 @@ jobs:
include:
- operating-system: "ubuntu-latest"
php-version: "8.1"
- operating-system: "ubuntu-latest"
php-version: "8.2"
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
Expand All @@ -74,10 +78,12 @@ jobs:
include:
- operating-system: "ubuntu-latest"
php-version: "8.1"
- operating-system: "ubuntu-latest"
php-version: "8.2"
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
Expand All @@ -97,6 +103,7 @@ jobs:
- name: PHPUnit
uses: php-actions/phpunit@v3
env:
XDEBUG_MODE: coverage
FO_ID_DS: '${{ secrets.FO_ID_DS }}'
FO_LOGIN_USER: '${{ secrets.FO_LOGIN_USER }}'
FO_PASSWORD_USER: '${{ secrets.FO_PASSWORD_USER }}'
Expand All @@ -115,3 +122,4 @@ jobs:
configuration: phpunit.xml
php_version: "${{ matrix.php-version }}"
php_extensions: "${{ env.extensions }}"
version: "10.2"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
composer.lock
vendor
.phpunit.result.cache
.phpunit.cache
tests/_data/test.p12
tests/_reports
.data
.data
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ RUN apt-get -y --no-install-recommends update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* /var/cache/apt/lists
COPY --from=builder /var/www .
COPY . ./
COPY . ./
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
}
],
"require": {
"php": "^8.1",
"php": ">=8.1",
"ext-curl": "*",
"ext-dom": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-xml": "*",
"symfony/validator": "^6.3",
"symfony/validator": "^6.0",
"tomas-kulhanek/serializer": "^2.0"
},
"autoload": {
Expand All @@ -57,7 +57,7 @@
"nyholm/psr7": "^1.4",
"php-http/httplug": "^2.2",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^10.2",
"rector/rector": "^0.17.7",
"symfony/http-client": "5.4.*|6.*",
"symplify/easy-coding-standard": "^12.0"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ services:
context: .
target: development
volumes:
- ./:/var/www
- ./:/var/www
35 changes: 14 additions & 21 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true"
testdox="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="./tests/_reports"/>
<text outputFile="php://stdout" showUncoveredFiles="true"/>
</report>
</coverage>
<testsuites>
<testsuite name="main">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<logging/>
</phpunit>
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false" beStrictAboutCoverageMetadata="false">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
]);

// Define what rule sets will be applied
$containerConfigurator->import(LevelSetList::UP_TO_PHP_81);
$containerConfigurator->import(LevelSetList::UP_TO_PHP_80);

$containerConfigurator->phpstanConfig( __DIR__ . '/phpstan.neon');
$containerConfigurator->skip([
Expand Down
8 changes: 4 additions & 4 deletions src/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class Account
{
final public const LOGIN_NAME_PASSWORD = 'password';
final public const LOGIN_SPIS_CERT = 'cert';
final public const LOGIN_CERT_LOGIN_NAME_PASSWORD = 'certPassword';
final public const LOGIN_HOSTED_SPIS = 'hosted';
public const LOGIN_NAME_PASSWORD = 'password';
public const LOGIN_SPIS_CERT = 'cert';
public const LOGIN_CERT_LOGIN_NAME_PASSWORD = 'certPassword';
public const LOGIN_HOSTED_SPIS = 'hosted';

private ?string $loginName = null;

Expand Down
6 changes: 3 additions & 3 deletions src/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@

class Connector
{
private readonly ClientProviderInterface $provider;
private ClientProviderInterface $provider;

private readonly SerializerInterface $serializer;
private SerializerInterface $serializer;

public function __construct(SerializerInterface $serializer, ClientProviderInterface $provider)
{
Expand Down Expand Up @@ -131,7 +131,7 @@ public function authenticateMessage(Account $account, AuthenticateMessage $input
{
return $this->send($account, EndpointProvider::OPERATIONS, $input, DTO\Response\AuthenticateMessage::class);
}

public function getUserInfoFromLogin(Account $account): GetUserInfoFromLogin
{
return $this->send($account, EndpointProvider::ACCESS, (new DTO\Request\GetUserInfoFromLogin()), GetUserInfoFromLogin::class);
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/Envelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#[Serializer\XmlRoot(name: 'p:dmEnvelope')]
#[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')]
#[Serializer\AccessorOrder(custom: ['senderOrgUnit', 'senderOrgUnitNum', 'annotation', 'recipientRefNumber', 'senderRefNumber', 'recipientIdent', 'senderIdent', 'legalTitleLaw', 'legalTitleYear', 'legalTitleSect', 'legalTitlePar', 'legalTitlePoint', 'personalDelivery', 'allowSubstDelivery', 'ovm', 'publishOwnId'])]
#[Serializer\AccessorOrder(order: 'custom', custom: ['senderOrgUnit', 'senderOrgUnitNum', 'annotation', 'recipientRefNumber', 'senderRefNumber', 'recipientIdent', 'senderIdent', 'legalTitleLaw', 'legalTitleYear', 'legalTitleSect', 'legalTitlePar', 'legalTitlePoint', 'personalDelivery', 'allowSubstDelivery', 'ovm', 'publishOwnId'])]
class Envelope
{
use DataMessageEnvelopeSub;
Expand Down
9 changes: 1 addition & 8 deletions src/DTO/Request/CreateMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')]
#[Serializer\XmlRoot(name: 'p:CreateMultipleMessage', namespace: 'http://isds.czechpoint.cz/v20')]
#[Serializer\AccessorOrder(custom: ['recipients', 'envelope', 'files'])]
#[Serializer\AccessorOrder(order: 'custom', custom: ['recipients', 'envelope', 'files'])]
class CreateMessage implements IRequest
{
use GetMainFile;
Expand Down Expand Up @@ -50,17 +50,11 @@ class CreateMessage implements IRequest
#[Assert\Valid()]
protected array $recipients = [];

/**
* @return Envelope
*/
public function getEnvelope(): Envelope
{
return $this->envelope;
}

/**
* @return CreateMessage
*/
public function setEnvelope(Envelope $envelope): CreateMessage
{
$this->envelope = $envelope;
Expand All @@ -77,7 +71,6 @@ public function getFiles(): array

/**
* @param File[] $files
* @return CreateMessage
*/
public function setFiles(array $files): CreateMessage
{
Expand Down
6 changes: 3 additions & 3 deletions src/DTO/Request/DataBoxCreditInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@

#[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')]
#[Serializer\XmlRoot(name: 'p:DataBoxCreditInfo', namespace: 'http://isds.czechpoint.cz/v20')]
#[Serializer\AccessorOrder(custom: ['dataBoxId', 'fromDate', 'toDate'])]
#[Serializer\AccessorOrder(order: 'custom', custom: ['dataBoxId', 'fromDate', 'toDate'])]
class DataBoxCreditInfo implements IRequest
{
use DataBoxId;

#[Serializer\Type("DateTimeImmutable<'Y-m-d'>")]
#[Serializer\XmlElement(cdata: false)]
#[Serializer\SerializedName('p:ciFromDate')]
private readonly DateTimeImmutable $fromDate;
private DateTimeImmutable $fromDate;

#[Serializer\Type("DateTimeImmutable<'Y-m-d'>")]
#[Serializer\XmlElement(cdata: false)]
#[Serializer\SerializedName('p:ciTodate')]
private readonly DateTimeImmutable $toDate;
private DateTimeImmutable $toDate;

public function __construct(DateTimeImmutable $fromDate, DateTimeImmutable $toDate)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/Request/GetDataBoxActivityStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')]
#[Serializer\XmlRoot(name: 'p:GetDataBoxActivityStatus', namespace: 'http://isds.czechpoint.cz/v20')]
#[Serializer\AccessorOrder(custom: ['dataBoxId', 'from', 'to'])]
#[Serializer\AccessorOrder(order: 'custom', custom: ['dataBoxId', 'from', 'to'])]
class GetDataBoxActivityStatus implements IRequest
{
use DataBoxId;
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/Response/CreateMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')]
#[Serializer\XmlRoot(name: 'p:CreateMultipleMessageResponse', namespace: 'http://isds.czechpoint.cz/v20')]
#[Serializer\AccessorOrder(custom: ['messageStatus', 'status'])]
#[Serializer\AccessorOrder(order: 'custom', custom: ['messageStatus', 'status'])]
class CreateMessage extends IResponse
{
use DataMessageStatus;
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/Response/FindPersonalDataBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FindPersonalDataBox extends IResponse
new Assert\Type(type: PersonalOwnerInfo::class)
])]
#[Assert\Valid()]
protected $record;
protected array $record = [];

/**
* @return PersonalOwnerInfo[]
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/Response/GetMessageStateChanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GetMessageStateChanges extends IResponse
#[Serializer\XmlList(entry: 'dmRecord', inline: false)]
#[Serializer\SerializedName('p:dmRecords')]
#[Assert\All([
new Assert\Type(type: StateChangeRecord::class)
new Assert\Type(StateChangeRecord::class)
])]
#[Assert\Valid()]
protected array $record = [];
Expand Down
2 changes: 1 addition & 1 deletion src/DTO/Response/SignedSentMessageDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#[Serializer\XmlNamespace(uri: 'http://isds.czechpoint.cz/v20', prefix: 'p')]
#[Serializer\XmlRoot(name: 'p:SignedSentMessageDownloadResponse', namespace: 'http://isds.czechpoint.cz/v20')]
#[Serializer\AccessorOrder(custom: ['signature', 'status'])]
#[Serializer\AccessorOrder(order: 'custom', custom: ['signature', 'status'])]
class SignedSentMessageDownload extends IResponse
{
use DataMessageStatus;
Expand Down
10 changes: 5 additions & 5 deletions src/Provider/EndpointProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

class EndpointProvider
{
final public const OPERATIONS = 0;
final public const INFO = 1;
final public const SEARCH = 2;
final public const SUPPLEMENTARY = 3;
final public const ACCESS = 5;
public const OPERATIONS = 0;
public const INFO = 1;
public const SEARCH = 2;
public const SUPPLEMENTARY = 3;
public const ACCESS = 5;

private function getServiceDomain(bool $isProduction): string
{
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/GuzzleClientProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

class GuzzleClientProvider implements ClientProviderInterface
{
private readonly Client $client;
private readonly EndpointProvider $endpointProvider;
private Client $client;
private EndpointProvider $endpointProvider;

public static function create(): self
{
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/SymfonyClientProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

class SymfonyClientProvider implements ClientProviderInterface
{
private readonly HttpClientInterface $client;
private readonly EndpointProvider $endpointProvider;
private HttpClientInterface $client;
private EndpointProvider $endpointProvider;


public static function create(): self
Expand Down
2 changes: 2 additions & 0 deletions src/Traits/DataMessageStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace TomasKulhanek\CzechDataBox\Traits;

use JMS\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
use TomasKulhanek\CzechDataBox\DTO\Response\IResponseStatus;

trait DataMessageStatus
{
#[Serializer\Type(\TomasKulhanek\CzechDataBox\DTO\DataMessageStatus::class)]
#[Serializer\SerializedName('p:dmStatus')]
#[Serializer\XmlElement(cdata: false)]
#[Assert\Valid()]
protected IResponseStatus $status;

public function getStatus(): IResponseStatus
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/BinarySuffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

class BinarySuffix
{
final public const CONVERT_THRESHOLD = 1024;
public const CONVERT_THRESHOLD = 1024;

private readonly int $number;
private int $number;

/**
* @var array<int,string>
Expand Down
Loading

0 comments on commit ff4eff3

Please sign in to comment.