Skip to content

Commit

Permalink
style: fix DoctrineORMLoaderTest
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek committed Nov 14, 2023
1 parent 2493830 commit 881372b
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions tests/Unit/Loader/DoctrineORMLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace BenTools\ETL\Tests\Unit\Loader;

use BenTools\ETL\EtlConfiguration;
use BenTools\ETL\EtlExecutor;
use BenTools\ETL\EtlState;
use BenTools\ETL\Exception\LoadException;
use BenTools\ETL\Loader\DoctrineORMLoader;
Expand All @@ -15,21 +13,18 @@
use Mockery;
use stdClass;

use function BenTools\ETL\loadInto;

it('works', function () {
$registry = Mockery::mock(ManagerRegistry::class);
$manager = Mockery::mock(ObjectManager::class);
$registry->shouldReceive('getManagerForClass')->andReturn($manager);
$manager->shouldReceive('persist')->twice();
$manager->shouldReceive('flush')->once();

$executor = (new EtlExecutor(options: new EtlConfiguration(flushEvery: 10)))
->transformWith(function (array $book) {
yield new Book($book['id'], $book['name']);
})
->loadInto(new DoctrineORMLoader($registry));
$executor->process([
['id' => 1, 'name' => 'Holy Bible'],
['id' => 2, 'name' => 'Fifty Shades of Grey'],
loadInto(new DoctrineORMLoader($registry))->process([
new Book(id: 1, name: 'Holy Bible'),
new Book(id: 2, name: 'Fifty Shades of Grey'),
]);
});

Expand Down

0 comments on commit 881372b

Please sign in to comment.