-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
495 additions
and
22 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 |
---|---|---|
|
@@ -6,10 +6,11 @@ | |
"authors": [ | ||
{ | ||
"name": "Manuel Bertrams", | ||
"email": "[email protected]" | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"cocur/slugify": "^4.0", | ||
"dantleech/phpcr-migrations-bundle": "^1.2", | ||
"php": "^7.1.3", | ||
"sulu/sulu": "^2.2", | ||
|
@@ -18,15 +19,14 @@ | |
"symfony/framework-bundle": "^4.0 | ^5.0", | ||
"symfony/http-foundation": "^4.0 | ^5.0", | ||
"symfony/http-kernel": "^4.0 | ^5.0", | ||
"cocur/slugify": "^4.0", | ||
"symfony/translation": "^5.2", | ||
"symfony/intl": "^5.2" | ||
"symfony/intl": "^5.2", | ||
"symfony/translation": "^5.2" | ||
}, | ||
"require-dev": { | ||
"symfony/phpunit-bridge": "^4.0 | ^5.0", | ||
"symfony/framework-bundle": "^4.0 | ^5.0", | ||
"jackalope/jackalope-doctrine-dbal": "^1.3.4", | ||
"symfony/browser-kit": "^4.0 | ^5.0", | ||
"jackalope/jackalope-doctrine-dbal": "^1.3.4" | ||
"symfony/phpunit-bridge": "^4.0 | ^5.0", | ||
"symfony/console": "^4.0 | ^5.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
|
@@ -37,5 +37,8 @@ | |
"psr-4": { | ||
"Manuxi\\SuluEventBundle\\Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
|
||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Manuxi\SuluEventBundle\Tests\App; | ||
|
||
use Manuxi\SuluEventBundle\SuluEventBundle; | ||
use Sulu\Bundle\TestBundle\Kernel\SuluTestKernel; | ||
use Symfony\Component\HttpKernel\Bundle\BundleInterface; | ||
|
||
class Kernel extends SuluTestKernel | ||
{ | ||
/** | ||
* @return BundleInterface[] | ||
*/ | ||
public function registerBundles(): array | ||
{ | ||
/** @var BundleInterface[] $bundles */ | ||
$bundles = parent::registerBundles(); | ||
$bundles[] = new SuluEventBundle(); | ||
|
||
return $bundles; | ||
} | ||
|
||
public function getProjectDir(): string | ||
{ | ||
return __DIR__; | ||
} | ||
} |
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,76 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Manuxi\SuluEventBundle\Tests\Unit\Content\Type; | ||
|
||
use Manuxi\SuluEventBundle\Content\Type\EventSelection; | ||
use Manuxi\SuluEventBundle\Entity\Event; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\Persistence\ObjectRepository; | ||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\Prophecy\ObjectProphecy; | ||
use Sulu\Component\Content\Compat\PropertyInterface; | ||
|
||
class EventSelectionTest extends TestCase | ||
{ | ||
private $eventSelection; | ||
|
||
/** | ||
* @var ObjectProphecy<ObjectRepository<Event>> | ||
*/ | ||
private $eventRepository; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->eventRepository = $this->prophesize(ObjectRepository::class); | ||
$entityManager = $this->prophesize(EntityManagerInterface::class); | ||
$entityManager->getRepository(Event::class)->willReturn($this->eventRepository->reveal()); | ||
|
||
$this->eventSelection = new EventSelection($entityManager->reveal()); | ||
} | ||
|
||
public function testNullValue(): void | ||
{ | ||
$property = $this->prophesize(PropertyInterface::class); | ||
$property->getValue()->willReturn(null); | ||
|
||
$this->assertSame([], $this->eventSelection->getContentData($property->reveal())); | ||
$this->assertSame(['ids' => null], $this->eventSelection->getViewData($property->reveal())); | ||
} | ||
|
||
public function testEmptyArrayValue(): void | ||
{ | ||
$property = $this->prophesize(PropertyInterface::class); | ||
$property->getValue()->willReturn([]); | ||
|
||
$this->assertSame([], $this->eventSelection->getContentData($property->reveal())); | ||
$this->assertSame(['ids' => []], $this->eventSelection->getViewData($property->reveal())); | ||
} | ||
|
||
public function testValidValue(): void | ||
{ | ||
$property = $this->prophesize(PropertyInterface::class); | ||
$property->getValue()->willReturn([45, 22]); | ||
|
||
$event22 = $this->prophesize(Event::class); | ||
$event22->getId()->willReturn(22); | ||
|
||
$event45 = $this->prophesize(Event::class); | ||
$event45->getId()->willReturn(45); | ||
|
||
$this->eventRepository->findBy(['id' => [45, 22]])->willReturn([ | ||
$event22->reveal(), | ||
$event45->reveal(), | ||
]); | ||
|
||
$this->assertSame( | ||
[ | ||
$event45->reveal(), | ||
$event22->reveal(), | ||
], | ||
$this->eventSelection->getContentData($property->reveal()) | ||
); | ||
$this->assertSame(['ids' => [45, 22]], $this->eventSelection->getViewData($property->reveal())); | ||
} | ||
} |
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,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Manuxi\SuluEventBundle\Tests\Unit\Content\Type; | ||
|
||
use Manuxi\SuluEventBundle\Content\Type\SingleEventSelection; | ||
use Manuxi\SuluEventBundle\Entity\Event; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\Persistence\ObjectRepository; | ||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\Prophecy\ObjectProphecy; | ||
use Sulu\Component\Content\Compat\PropertyInterface; | ||
|
||
class SingleEventSelectionTest extends TestCase | ||
{ | ||
private $singleEventSelection; | ||
|
||
/** | ||
* @var ObjectProphecy<ObjectRepository<Event>> | ||
*/ | ||
private $eventRepository; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->eventRepository = $this->prophesize(ObjectRepository::class); | ||
$entityManager = $this->prophesize(EntityManagerInterface::class); | ||
$entityManager->getRepository(Event::class)->willReturn($this->eventRepository->reveal()); | ||
|
||
$this->singleEventSelection = new SingleEventSelection($entityManager->reveal()); | ||
} | ||
|
||
public function testNullValue(): void | ||
{ | ||
$property = $this->prophesize(PropertyInterface::class); | ||
$property->getValue()->willReturn(null); | ||
|
||
$this->assertNull($this->singleEventSelection->getContentData($property->reveal())); | ||
$this->assertSame(['id' => null], $this->singleEventSelection->getViewData($property->reveal())); | ||
} | ||
|
||
public function testValidValue(): void | ||
{ | ||
$property = $this->prophesize(PropertyInterface::class); | ||
$property->getValue()->willReturn(45); | ||
|
||
$event45 = $this->prophesize(Event::class); | ||
|
||
$this->eventRepository->find(45)->willReturn($event45->reveal()); | ||
|
||
$this->assertSame($event45->reveal(), $this->singleEventSelection->getContentData($property->reveal())); | ||
$this->assertSame(['id' => 45], $this->singleEventSelection->getViewData($property->reveal())); | ||
} | ||
} |
Oops, something went wrong.