-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dispatch events on import success / failure (#33)
* dispatch events on import success / failure
- Loading branch information
1 parent
f73b2a1
commit 4e7e055
Showing
10 changed files
with
319 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Fastbolt Schraubengroßhandels GmbH. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Fastbolt\EntityImporter\Events; | ||
|
||
use DateTimeInterface; | ||
use Exception; | ||
use Fastbolt\EntityImporter\EntityImporterDefinition; | ||
|
||
class ImportFailureEvent | ||
{ | ||
/** | ||
* @var Exception | ||
*/ | ||
private Exception $exception; | ||
|
||
/** | ||
* @var EntityImporterDefinition|null | ||
*/ | ||
private ?EntityImporterDefinition $definition; | ||
|
||
/** | ||
* @var DateTimeInterface | ||
*/ | ||
private DateTimeInterface $importStart; | ||
|
||
/** | ||
* @param EntityImporterDefinition|null $definition | ||
* @param DateTimeInterface $importStart | ||
* @param Exception $exception | ||
*/ | ||
public function __construct( | ||
?EntityImporterDefinition $definition, | ||
DateTimeInterface $importStart, | ||
Exception $exception | ||
) { | ||
$this->definition = $definition; | ||
$this->importStart = $importStart; | ||
$this->exception = $exception; | ||
} | ||
|
||
/** | ||
* @return Exception | ||
*/ | ||
public function getException(): Exception | ||
{ | ||
return $this->exception; | ||
} | ||
|
||
/** | ||
* @return EntityImporterDefinition|null | ||
*/ | ||
public function getDefinition(): ?EntityImporterDefinition | ||
{ | ||
return $this->definition; | ||
} | ||
|
||
/** | ||
* @return DateTimeInterface | ||
*/ | ||
public function getImportStart(): DateTimeInterface | ||
{ | ||
return $this->importStart; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Fastbolt Schraubengroßhandels GmbH. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Fastbolt\EntityImporter\Events; | ||
|
||
use DateTimeInterface; | ||
use Fastbolt\EntityImporter\EntityImporterDefinition; | ||
use Fastbolt\EntityImporter\Types\ImportResult; | ||
|
||
class ImportSuccessEvent | ||
{ | ||
/** | ||
* @var ImportResult | ||
*/ | ||
private ImportResult $importResult; | ||
|
||
/** | ||
* @var EntityImporterDefinition | ||
*/ | ||
private EntityImporterDefinition $definition; | ||
|
||
/** | ||
* @var DateTimeInterface | ||
*/ | ||
private DateTimeInterface $importStart; | ||
|
||
/** | ||
* @param EntityImporterDefinition $definition | ||
* @param DateTimeInterface $importStart | ||
* @param ImportResult $importResult | ||
*/ | ||
public function __construct( | ||
EntityImporterDefinition $definition, | ||
DateTimeInterface $importStart, | ||
ImportResult $importResult | ||
) { | ||
$this->definition = $definition; | ||
$this->importStart = $importStart; | ||
$this->importResult = $importResult; | ||
} | ||
|
||
/** | ||
* @return ImportResult | ||
*/ | ||
public function getImportResult(): ImportResult | ||
{ | ||
return $this->importResult; | ||
} | ||
|
||
/** | ||
* @return EntityImporterDefinition | ||
*/ | ||
public function getDefinition(): EntityImporterDefinition | ||
{ | ||
return $this->definition; | ||
} | ||
|
||
/** | ||
* @return DateTimeInterface | ||
*/ | ||
public function getImportStart(): DateTimeInterface | ||
{ | ||
return $this->importStart; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Fastbolt Schraubengroßhandels GmbH. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Fastbolt\EntityImporter\Tests\Unit\Events; | ||
|
||
use DateTime; | ||
use Exception; | ||
use Fastbolt\EntityImporter\EntityImporterDefinition; | ||
use Fastbolt\EntityImporter\Events\ImportFailureEvent; | ||
use Fastbolt\TestHelpers\BaseTestCase; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
/** | ||
* @covers \Fastbolt\EntityImporter\Events\ImportFailureEvent | ||
*/ | ||
class ImportFailureEventTest extends BaseTestCase | ||
{ | ||
/** | ||
* @var Exception|MockObject | ||
*/ | ||
private $exception; | ||
|
||
/** | ||
* @var EntityImporterDefinition|MockObject | ||
*/ | ||
private $definition; | ||
|
||
public function testEvent(): void | ||
{ | ||
$event = new ImportFailureEvent($this->definition, $start = new DateTime(), $this->exception); | ||
|
||
self::assertSame($this->definition, $event->getDefinition()); | ||
self::assertSame($start, $event->getImportStart()); | ||
self::assertSame($this->exception, $event->getException()); | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->exception = $this->getMock(Exception::class); | ||
$this->definition = $this->getMock(EntityImporterDefinition::class); | ||
} | ||
} |
Oops, something went wrong.