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\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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user