Skip to content

Commit

Permalink
Release 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
curry684 committed Dec 5, 2023
1 parent 2c4758f commit d0503e8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
Nothing yet.

## 0.8.0 - in RC
## [0.8.0] - 2023-12-05
### Breaking
- All interfaces and classes are now fully typed, this will likely require modifications in any custom extensions
- Removed `DataTablesTrait` for use in controllers
Expand All @@ -17,7 +17,7 @@ Nothing yet.

### Changed
- Fix deprecations
- Add parameter and return types all over for static analysis purposes
- Add parameter and return types to all code
- Codebase is now at PHPstan level 8

## [0.7.2] - 2023-04-24
Expand Down Expand Up @@ -180,7 +180,8 @@ or break any applications.
### Added
- Basic functionality

[Unreleased]: https://github.com/omines/datatables-bundle/compare/0.7.2...master
[Unreleased]: https://github.com/omines/datatables-bundle/compare/0.8.0...master
[0.8.0]: https://github.com/omines/datatables-bundle/compare/0.7.2...0.8.0
[0.7.2]: https://github.com/omines/datatables-bundle/compare/0.7.1...0.7.2
[0.7.1]: https://github.com/omines/datatables-bundle/compare/0.7.0...0.7.1
[0.7.0]: https://github.com/omines/datatables-bundle/compare/0.6.0...0.7.0
Expand Down
6 changes: 2 additions & 4 deletions src/Column/DateTimeColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ public function normalize(mixed $value): mixed
if (!empty($this->options['createFromFormat'])) {
$value = \DateTime::createFromFormat($this->options['createFromFormat'], (string) $value);
if (false === $value) {
if (false === ($errors = \DateTime::getLastErrors())) {
throw new \LogicException('DateTime conversion failed for unknown reasons');
}
throw new \RuntimeException(implode(', ', $errors['errors'] ?: $errors['warnings']));
$errors = \DateTime::getLastErrors();
throw new \RuntimeException($errors ? implode(', ', $errors['errors'] ?: $errors['warnings']) : 'DateTime conversion failed for unknown reasons');
}
} else {
$value = new \DateTime((string) $value);
Expand Down
2 changes: 1 addition & 1 deletion src/Exporter/Csv/CsvExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function export(array $columnNames, \Iterator $data): \SplFileInfo
$filePath = sys_get_temp_dir() . '/' . uniqid('dt') . '.csv';

if (false === ($file = fopen($filePath, 'w'))) {
throw new \RuntimeException('Failed to create temporary file at ' . $filePath);
throw new \RuntimeException('Failed to create temporary file at ' . $filePath); // @codeCoverageIgnore
}

fputcsv($file, $columnNames);
Expand Down
9 changes: 9 additions & 0 deletions tests/Unit/Adapter/ORMAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

namespace Tests\Unit\Adapter;

use Doctrine\ORM\Query;
use Doctrine\ORM\Query\QueryException;
use Omines\DataTablesBundle\Adapter\Doctrine\Event\ORMAdapterQueryEvent;
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
use Omines\DataTablesBundle\DataTableFactory;
use Omines\DataTablesBundle\DataTableState;
Expand Down Expand Up @@ -40,4 +42,11 @@ public function testCountGroupedDataTable(): void
$adapter = $datatable->getAdapter();
$data = $adapter->getData(new DataTableState($datatable));
}

public function testORMAdapterQueryEvent(): void
{
$query = $this->createMock(Query::class);
$event = new ORMAdapterQueryEvent($query);
$this->assertSame($query, $event->getQuery());
}
}
3 changes: 3 additions & 0 deletions tests/Unit/ColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public function testDateTimeColumnWithCreateFromFormat(): void
], $this->createDataTable()->setName('foo'));

$this->assertSame('19.02.2020 22:30:34', $column->transform('2020-02-19T22:30:34+00:00'));

$this->expectExceptionMessage('four digit year');
$column->transform('foo.bar');
}

public function testTextColumn(): void
Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/DependencyInjectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@

namespace Tests\Unit;

use Omines\DataTablesBundle\Adapter\AdapterInterface;
use Omines\DataTablesBundle\DataTablesBundle;
use Omines\DataTablesBundle\DependencyInjection\Configuration;
use Omines\DataTablesBundle\DependencyInjection\Instantiator;
use Omines\DataTablesBundle\Exception\InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\ArrayNode;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -47,4 +50,13 @@ public function testExtension(): void
$this->assertTrue($config['language_from_cdn']);
$this->assertEmpty($config['options']);
}

public function testInstantiatorTypeChecks(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('must implement/extend ' . AdapterInterface::class);

$instantiator = new Instantiator();
$instantiator->getAdapter(\DateTimeImmutable::class);
}
}

0 comments on commit d0503e8

Please sign in to comment.