added annotation based exporter (#1831)
* added user exporter * added project exporter * added customer exporter * added activity exporter
This commit is contained in:
@@ -12,6 +12,9 @@ namespace App\Tests\Entity;
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\ActivityMeta;
|
||||
use App\Entity\Project;
|
||||
use App\Export\Spreadsheet\ColumnDefinition;
|
||||
use App\Export\Spreadsheet\Extractor\AnnotationExtractor;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -90,4 +93,36 @@ class ActivityTest extends TestCase
|
||||
self::assertEquals(3, $sut->getMetaFields()->count());
|
||||
self::assertCount(2, $sut->getVisibleMetaFields());
|
||||
}
|
||||
|
||||
public function testExportAnnotations()
|
||||
{
|
||||
$sut = new AnnotationExtractor(new AnnotationReader());
|
||||
|
||||
$columns = $sut->extract(Activity::class);
|
||||
|
||||
self::assertIsArray($columns);
|
||||
|
||||
$expected = [
|
||||
['label.id', 'integer'],
|
||||
['label.name', 'string'],
|
||||
['label.project', 'string'],
|
||||
['label.color', 'string'],
|
||||
['label.visible', 'boolean'],
|
||||
['label.comment', 'string'],
|
||||
];
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace App\Tests\Entity;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\CustomerMeta;
|
||||
use App\Entity\Team;
|
||||
use App\Export\Spreadsheet\ColumnDefinition;
|
||||
use App\Export\Spreadsheet\Extractor\AnnotationExtractor;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -145,4 +148,48 @@ class CustomerTest extends TestCase
|
||||
self::assertCount(0, $sut->getTeams());
|
||||
self::assertCount(0, $team->getCustomers());
|
||||
}
|
||||
|
||||
public function testExportAnnotations()
|
||||
{
|
||||
$sut = new AnnotationExtractor(new AnnotationReader());
|
||||
|
||||
$columns = $sut->extract(Customer::class);
|
||||
|
||||
self::assertIsArray($columns);
|
||||
|
||||
$expected = [
|
||||
['label.id', 'integer'],
|
||||
['label.name', 'string'],
|
||||
['label.company', 'string'],
|
||||
['label.number', 'string'],
|
||||
['label.vat_id', 'string'],
|
||||
['label.address', 'string'],
|
||||
['label.contact', 'string'],
|
||||
['label.email', 'string'],
|
||||
['label.phone', 'string'],
|
||||
['label.mobile', 'string'],
|
||||
['label.fax', 'string'],
|
||||
['label.homepage', 'string'],
|
||||
['label.country', 'string'],
|
||||
['label.currency', 'string'],
|
||||
['label.timezone', 'string'],
|
||||
['label.color', 'string'],
|
||||
['label.visible', 'boolean'],
|
||||
['label.comment', 'string'],
|
||||
];
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\ProjectMeta;
|
||||
use App\Entity\Team;
|
||||
use App\Export\Spreadsheet\ColumnDefinition;
|
||||
use App\Export\Spreadsheet\Extractor\AnnotationExtractor;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -133,4 +136,40 @@ class ProjectTest extends TestCase
|
||||
self::assertCount(0, $sut->getTeams());
|
||||
self::assertCount(0, $team->getProjects());
|
||||
}
|
||||
|
||||
public function testExportAnnotations()
|
||||
{
|
||||
$sut = new AnnotationExtractor(new AnnotationReader());
|
||||
|
||||
$columns = $sut->extract(Project::class);
|
||||
|
||||
self::assertIsArray($columns);
|
||||
|
||||
$expected = [
|
||||
['label.id', 'integer'],
|
||||
['label.name', 'string'],
|
||||
['label.customer', 'string'],
|
||||
['label.orderNumber', 'string'],
|
||||
['label.orderDate', 'datetime'],
|
||||
['label.project_start', 'datetime'],
|
||||
['label.project_end', 'datetime'],
|
||||
['label.color', 'string'],
|
||||
['label.visible', 'boolean'],
|
||||
['label.comment', 'string'],
|
||||
];
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user