Skip to content

Commit

Permalink
refactoring representation bundles (#515)
Browse files Browse the repository at this point in the history
✨ fetch entries according to permission
✨ move permission check from glue to zed
🐛 revocation fix after update cause of missed date comparing
  • Loading branch information
julianzimmermann committed Feb 1, 2024
1 parent 81d1add commit 86e62c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace FondOfOryx\Zed\RepresentativeCompanyUserTradeFairRestApi\Business\Model;

use DateTime;
use FondOfOryx\Shared\RepresentativeCompanyUserTradeFairRestApi\RepresentativeCompanyUserTradeFairRestApiConstants;
use FondOfOryx\Zed\RepresentativeCompanyUserTradeFairRestApi\Business\Model\Mapper\RestDataMapperInterface;
use FondOfOryx\Zed\RepresentativeCompanyUserTradeFairRestApi\Business\Validator\DurationValidatorInterface;
Expand Down Expand Up @@ -199,7 +200,10 @@ protected function getStatus(
RepresentativeCompanyUserTradeFairTransfer $representativeCompanyUserTradeFairTransfer,
RestRepresentativeCompanyUserTradeFairAttributesTransfer $representativeCompanyUserTradeFairAttributesTransfer
): bool {
if ($representativeCompanyUserTradeFairAttributesTransfer->getStartAt() < $representativeCompanyUserTradeFairTransfer->getStartAt()) {
$today = (new DateTime())->setTime(0, 0);
$startAt = new DateTime($representativeCompanyUserTradeFairAttributesTransfer->getStartAt());

if ($startAt < $today) {
return false;
}

Expand Down Expand Up @@ -258,13 +262,13 @@ protected function validate(

/**
* @param \Generated\Shared\Transfer\RestRepresentativeCompanyUserTradeFairRequestTransfer $restRepresentativeCompanyUserTradeFairRequestTransfer
* @param \Generated\Shared\Transfer\RestRepresentativeCompanyUserTradeFairAttributesTransfer|null $attributes
* @param \Generated\Shared\Transfer\RestRepresentativeCompanyUserTradeFairAttributesTransfer $attributes
*
* @return \Generated\Shared\Transfer\RepresentativeCompanyUserTradeFairFilterTransfer
*/
public function createFilter(
RestRepresentativeCompanyUserTradeFairRequestTransfer $restRepresentativeCompanyUserTradeFairRequestTransfer,
?RestRepresentativeCompanyUserTradeFairAttributesTransfer $attributes
RestRepresentativeCompanyUserTradeFairAttributesTransfer $attributes
): RepresentativeCompanyUserTradeFairFilterTransfer {
$restFilter = $restRepresentativeCompanyUserTradeFairRequestTransfer->getFilter();
$filter = new RepresentativeCompanyUserTradeFairFilterTransfer();
Expand All @@ -285,6 +289,7 @@ public function createFilter(
$filter->addSort((new RepresentativeCompanyUserFilterSortTransfer())->fromArray($sort->toArray(), true));
}
}
$filter->setRepresentative($attributes->getCustomerReferenceOriginator());
}

if ($attributes->getUuid() !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,6 @@ public function testUpdateTradeFairRepresentation(): void
->method('getStartAt')
->willReturn($date2);

$this->representativeCompanyUserTradeFairTransferMock->expects(static::atLeastOnce())
->method('getStartAt')
->willReturn($date1);

$this->restRepresentativeCompanyUserTradeFairAttributesTransferMock->expects(static::atLeastOnce())
->method('getEndAt')
->willReturn($date2);
Expand All @@ -421,10 +417,6 @@ public function testUpdateTradeFairRepresentation(): void
->with($date2)
->willReturnSelf();

$this->representativeCompanyUserTradeFairTransferMock->expects(static::atLeastOnce())
->method('getStartAt')
->willReturn($date1);

$this->restRepresentativeCompanyUserTradeFairAttributesTransferMock->expects(static::atLeastOnce())
->method('getStartAt')
->willReturn($date1);
Expand Down Expand Up @@ -814,18 +806,10 @@ public function testUpdateTradeFairRepresentationWithStatusFalse(): void
->method('getStartAt')
->willReturn($startAt1);

$this->representativeCompanyUserTradeFairTransferMock->expects(static::atLeastOnce())
->method('getStartAt')
->willReturn($startAt2);

$this->representativeCompanyUserTradeFairTransferMock->expects(static::atLeastOnce())
->method('setEndAt')
->willReturnSelf();

$this->representativeCompanyUserTradeFairTransferMock->expects(static::atLeastOnce())
->method('setStartAt')
->willReturnSelf();

$this->representativeCompanyUserTradeFairTransferMock->expects(static::atLeastOnce())
->method('setName')->with($name)
->willReturnSelf();
Expand Down

0 comments on commit 86e62c4

Please sign in to comment.