added annotation based exporter (#1831)

* added user exporter
* added project exporter
* added customer exporter
* added activity exporter
This commit is contained in:
Kevin Papst
2020-07-21 03:37:51 +02:00
committed by GitHub
parent 93a23f3fa3
commit aee063bb3c
79 changed files with 2980 additions and 215 deletions

View File

@@ -12,6 +12,9 @@ namespace App\Tests\Entity;
use App\Entity\Team;
use App\Entity\User;
use App\Entity\UserPreference;
use App\Export\Spreadsheet\ColumnDefinition;
use App\Export\Spreadsheet\Extractor\AnnotationExtractor;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Collections\ArrayCollection;
use PHPUnit\Framework\TestCase;
@@ -251,4 +254,41 @@ class UserTest extends TestCase
self::assertTrue($sut->canSeeAllData());
self::assertFalse($sut->initCanSeeAllData(true));
}
public function testExportAnnotations()
{
$sut = new AnnotationExtractor(new AnnotationReader());
$columns = $sut->extract(User::class);
self::assertIsArray($columns);
$expected = [
['label.id', 'integer'],
['label.username', 'string'],
['label.alias', 'string'],
['label.title', 'string'],
['label.email', 'string'],
['label.lastLogin', 'datetime'],
['label.language', 'string'],
['label.timezone', 'string'],
['label.active', 'boolean'],
['profile.registration_date', 'datetime'],
['label.roles', 'array'],
];
self::assertCount(\count($expected), $columns);
foreach ($columns as $column) {
self::assertInstanceOf(ColumnDefinition::class, $column);
}
$i = 0;
foreach ($expected as $item) {
$column = $columns[$i++];
self::assertEquals($item[0], $column->getLabel());
self::assertEquals($item[1], $column->getType());
}
}
}