Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Dec 22, 2022
1 parent 07892cb commit d5efce6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Choice/EntryChoice.php
Expand Up @@ -14,6 +14,7 @@

/**
* @deprecated use EncoreEntryOptionListener instead
* @codeCoverageIgnore
*/
class EntryChoice extends AbstractChoice
{
Expand Down
41 changes: 41 additions & 0 deletions tests/EventListener/Callback/EncoreEntryOptionListenerTest.php
@@ -0,0 +1,41 @@
<?php

/*
* Copyright (c) 2022 Heimrich & Hannot GmbH
*
* @license LGPL-3.0-or-later
*/

namespace HeimrichHannot\EncoreBundle\Test\EventListener\Callback;

use Contao\TestCase\ContaoTestCase;
use HeimrichHannot\EncoreBundle\Collection\EntryCollection;
use HeimrichHannot\EncoreBundle\EventListener\Callback\EncoreEntryOptionListener;

class EncoreEntryOptionListenerTest extends ContaoTestCase
{
public function createTestInstance(array $parameters = []): EncoreEntryOptionListener
{
$entryCollection = $parameters['entryCollection'] ?? $this->createMock(EntryCollection::class);

return new EncoreEntryOptionListener($entryCollection);
}

public function testGetEntriesAsOptions()
{
$instance = $this->createTestInstance();
$this->assertEmpty($instance->getEntriesAsOptions());

$entryCollection = $this->createMock(EntryCollection::class);
$entryCollection->method('getEntries')->willReturn([
['name' => 'hello'],
['name' => 'abcd', 'file' => 'abcd.js'],
]);

$instance = $this->createTestInstance(['entryCollection' => $entryCollection]);
$this->assertSame([
'abcd' => 'abcd [abcd.js]',
'hello' => 'hello',
], $instance->getEntriesAsOptions());
}
}

0 comments on commit d5efce6

Please sign in to comment.