Move all files to tome/
This commit is contained in:
parent
5675bcfc36
commit
674daab35b
2874 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,28 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- field.storage.node.field_podcast_guests
|
||||
- node.type.podcast_episode
|
||||
- taxonomy.vocabulary.podcast_guest
|
||||
id: node.podcast_episode.field_podcast_guests
|
||||
field_name: field_podcast_guests
|
||||
entity_type: node
|
||||
bundle: podcast_episode
|
||||
label: Guests
|
||||
description: ''
|
||||
required: false
|
||||
translatable: false
|
||||
default_value: { }
|
||||
default_value_callback: ''
|
||||
settings:
|
||||
handler: 'default:taxonomy_term'
|
||||
handler_settings:
|
||||
target_bundles:
|
||||
podcast_guest: podcast_guest
|
||||
sort:
|
||||
field: name
|
||||
direction: asc
|
||||
auto_create: true
|
||||
auto_create_bundle: ''
|
||||
field_type: entity_reference
|
|
@ -0,0 +1,19 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
- taxonomy
|
||||
id: node.field_podcast_guests
|
||||
field_name: field_podcast_guests
|
||||
entity_type: node
|
||||
type: entity_reference
|
||||
settings:
|
||||
target_type: taxonomy_term
|
||||
module: core
|
||||
locked: false
|
||||
cardinality: -1
|
||||
translatable: true
|
||||
indexes: { }
|
||||
persist_with_no_fields: false
|
||||
custom_storage: false
|
|
@ -0,0 +1,11 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
third_party_settings: { }
|
||||
name: 'Podcast episode'
|
||||
type: podcast_episode
|
||||
description: null
|
||||
help: null
|
||||
new_revision: true
|
||||
preview_mode: 1
|
||||
display_submitted: true
|
|
@ -0,0 +1,8 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
name: 'Podcast guest'
|
||||
vid: podcast_guest
|
||||
description: null
|
||||
weight: 0
|
||||
new_revision: false
|
|
@ -0,0 +1,8 @@
|
|||
name: Podcast Test
|
||||
description: A test module for podcasts.
|
||||
core_version_requirement: ^11
|
||||
type: module
|
||||
package: oliverdavies.uk
|
||||
hidden: true
|
||||
dependencies:
|
||||
- drupal:node
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\opd_podcast\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\Tests\token\Functional\TokenTestTrait;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\opd_podcast\Episode;
|
||||
use Drupal\opd_podcast\Guest;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\TermInterface;
|
||||
|
||||
class PodcastTokenTest extends BrowserTestBase {
|
||||
|
||||
use NodeCreationTrait;
|
||||
use TokenTestTrait;
|
||||
|
||||
public $defaultTheme = 'stark';
|
||||
|
||||
protected static $modules = [
|
||||
'opd_podcast',
|
||||
'opd_podcast_test',
|
||||
'taxonomy',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param non-empty-string[] $guestNames
|
||||
* @param non-empty-string $expected
|
||||
*
|
||||
* @dataProvider podcastNodeProvider
|
||||
*/
|
||||
public function test_guest_name_token(array $guestNames, string $expected): void {
|
||||
$node = $this->createPodcastNode(
|
||||
guestNames: $guestNames,
|
||||
);
|
||||
|
||||
$this->assertToken(
|
||||
data: ['node' => $node],
|
||||
expected: $expected,
|
||||
token: 'guest-names',
|
||||
type: 'opd-podcast',
|
||||
);
|
||||
}
|
||||
|
||||
public function podcastNodeProvider(): \Generator {
|
||||
return [
|
||||
yield 'Single guest' => [['Matt Glaman'], 'Matt Glaman'],
|
||||
yield 'Two guests' => [['Emma Horrell', 'Luke McCormick'], 'Emma Horrell and Luke McCormick'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, non-empty-string> $guestNames
|
||||
*
|
||||
* @return list<TermInterface>
|
||||
*/
|
||||
private function createGuestTerms(array $guestNames): array {
|
||||
return array_map(
|
||||
array: $guestNames,
|
||||
callback: fn (string $guestName): TermInterface => Term::create([
|
||||
'name' => $guestName,
|
||||
'vid' => Guest::TERM_TYPE,
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param non-empty-string[] $guestNames
|
||||
*/
|
||||
private function createPodcastNode(array $guestNames): NodeInterface {
|
||||
return $this->createNode([
|
||||
'field_podcast_guests' => $this->createGuestTerms($guestNames),
|
||||
'title' => '::title::',
|
||||
'type' => Episode::NODE_TYPE,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\opd_podcast\Functional;
|
||||
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\opd_podcast\Episode;
|
||||
use Drupal\opd_podcast\Repository\PodcastNodeRepository;
|
||||
|
||||
class PodcastNodeRepositoryTest extends EntityKernelTestBase {
|
||||
|
||||
use NodeCreationTrait;
|
||||
|
||||
protected static $modules = [
|
||||
'node',
|
||||
'opd_podcast',
|
||||
'taxonomy',
|
||||
];
|
||||
|
||||
public function test_it_returns_published_podcast_episodes(): void {
|
||||
$this->createEpisode([
|
||||
'title' => 'Episode A',
|
||||
'status' => NodeInterface::PUBLISHED,
|
||||
]);
|
||||
|
||||
$this->createEpisode([
|
||||
'title' => 'Episode B',
|
||||
'status' => NodeInterface::NOT_PUBLISHED,
|
||||
]);
|
||||
|
||||
$this->createEpisode([
|
||||
'title' => 'Episode C',
|
||||
'status' => NodeInterface::PUBLISHED,
|
||||
]);
|
||||
|
||||
$this->createEpisode([
|
||||
'title' => 'Episode D',
|
||||
'status' => NodeInterface::PUBLISHED,
|
||||
]);
|
||||
|
||||
$repository = $this->container->get(PodcastNodeRepository::class);
|
||||
|
||||
$episodes = $repository->getPublished();
|
||||
|
||||
$this->assertCount(expectedCount: 3, haystack: $episodes);
|
||||
|
||||
$titles = array_map(
|
||||
array: $episodes,
|
||||
callback: fn (NodeInterface $episode): string => (string) $episode->getTitle(),
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
actual: array_values($titles),
|
||||
expected: ['Episode A', 'Episode C', 'Episode D'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<non-empty-string, mixed> $values
|
||||
*/
|
||||
private function createEpisode(array $values): NodeInterface {
|
||||
return $this->createNode([
|
||||
'type' => Episode::NODE_TYPE,
|
||||
...$values,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue