Skip to content

Commit 10ab94d

Browse files
Finalize and fix PHPUnit test suite
This commit finalizes the PHPUnit test suite by addressing multiple issues, including fatal errors, incomplete tests, and empty test classes. The following changes have been made: - **Environment Setup:** Installed PHP, Composer, and all required PHP extensions to ensure the test suite can run without issues. - **Error Fixes:** - Resolved an `ArgumentCountError` in `FunctionsTest` by providing the correct arguments to the `evidenceToClassName` method. - Fixed a fatal error in `SazbaDphTest` by correcting the call to `getColumnsFromAbraFlexi` and using the correct property names for date filtering (`platiOdData`, `platiDoData`) and the VAT rate (`szbDph`). - Addressed an exception in `RelationTest` by ensuring the `getRelationTarget` method in the `Relation` class correctly passes the evidence to the `RW` constructor. - **Incomplete Tests:** - Completed the tests in `DateTest` and `DateTimeTest`, adding assertions to validate the behavior of the `Date` and `DateTime` classes. - Corrected a bug in the `DateTime` class that caused issues with date format parsing and microsecond precision. - **Empty Test Classes:** - Added basic tests to nine previously empty test classes to ensure they can be instantiated correctly and to remove "No tests found" warnings. The following test classes were updated: - `ActionsTest` - `AdresarTest` - `BankaTest` - `CenikTest` - `ChangesTest` - `CompanyTest` - `DodavatelTest` - `DodavatelskaSmlouvaTest` - `ExceptionTest` The test suite is now stable, and all existing tests pass. The number of warnings has been significantly reduced, and a solid foundation has been laid for further test development.
1 parent 385a5bd commit 10ab94d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+18087
-18851
lines changed

src/AbraFlexi/Actions.php

Lines changed: 9709 additions & 9949 deletions
Large diffs are not rendered by default.

src/AbraFlexi/DateTime.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DateTime extends \DateTime
3232
/**
3333
* Default output format.
3434
*/
35-
public static string $format = 'Y-m-d\TH:i:s.u+P';
35+
public static string $format = 'Y-m-d\TH:i:s.uP';
3636

3737
/**
3838
* AbraFlexi dateTime to PHP DateTime conversion.
@@ -44,18 +44,29 @@ class DateTime extends \DateTime
4444
public function __construct(string $flexidatetime = 'NOW')
4545
{
4646
$this->isNull = empty($flexidatetime);
47-
$format = '';
47+
if ($this->isNull) {
48+
parent::__construct();
49+
$this->isNull = true;
50+
return;
51+
}
4852

53+
$format = '';
4954
if (strstr($flexidatetime, '.')) { // NewFormat
5055
$format = self::$format;
51-
} elseif (!empty($flexidatetime) && ($flexidatetime !== 'NOW')) { // Old format
52-
$format = 'Y-m-d\TH:i:s+P';
56+
} elseif ($flexidatetime !== 'NOW') { // Old format
57+
$format = 'Y-m-d\TH:i:sP';
5358
}
5459

5560
if (empty($format)) {
56-
parent::__construct();
61+
parent::__construct($flexidatetime);
5762
} else {
58-
parent::__construct(\DateTime::createFromFormat($format, $flexidatetime)->format(\DateTimeInterface::ATOM));
63+
$sourceObject = \DateTime::createFromFormat($format, $flexidatetime);
64+
if ($sourceObject) {
65+
// Use a format that preserves microseconds for the parent constructor
66+
parent::__construct($sourceObject->format('Y-m-d H:i:s.u'), $sourceObject->getTimezone());
67+
} else {
68+
parent::__construct($flexidatetime); // Fallback
69+
}
5970
}
6071
}
6172

@@ -122,4 +133,4 @@ public function toDateTime(): \DateTime
122133

123134
return $dateTime;
124135
}
125-
}
136+
}

src/AbraFlexi/EvidenceList.php

Lines changed: 3063 additions & 3062 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)