Rename custom module directories
- Rename `opdavies_blog` to `blog`. - Rename `opdavies_blog_test` to `blog_test`. - Rename `opdavies_talks` to `talks`. - Rename `opdavies_talks_test` to `talks_test`. The files within the directories haven't changed, so there is no breaking change caused by renaming the directories. Please enter the commit message for your changes. Lines starting
This commit is contained in:
parent
d7d5a6c8a3
commit
cbe60209e6
59 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\custom\Kernel\Entity\Node;
|
||||
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\opdavies_blog_test\Factory\PostFactory;
|
||||
|
||||
final class PostTest extends EntityKernelTestBase {
|
||||
|
||||
public static $modules = [
|
||||
// Core.
|
||||
'node',
|
||||
'link',
|
||||
'taxonomy',
|
||||
|
||||
// Contrib.
|
||||
'discoverable_entity_bundle_classes',
|
||||
|
||||
// Custom.
|
||||
'opdavies_blog',
|
||||
'opdavies_blog_test',
|
||||
];
|
||||
|
||||
/** @test */
|
||||
public function it_can_determine_if_a_post_contains_a_tweet(): void {
|
||||
$post = (new PostFactory())->create();
|
||||
$post->save();
|
||||
|
||||
$this->assertFalse($post->hasTweet());
|
||||
|
||||
$post = (new PostFactory())->create(['field_has_tweet' => TRUE]);
|
||||
$post->save();
|
||||
|
||||
$this->assertTrue($post->hasTweet());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_converts_a_post_to_a_tweet(): void {
|
||||
$post = (new PostFactory())
|
||||
->setTitle('Creating a custom PHPUnit command for DDEV')
|
||||
->withTags(['Automated testing', 'DDEV', 'Drupal', 'Drupal 8', 'PHP'])
|
||||
->create();
|
||||
|
||||
$post->save();
|
||||
|
||||
$expected = <<<EOF
|
||||
Creating a custom PHPUnit command for DDEV
|
||||
|
||||
http://localhost/node/1
|
||||
|
||||
#AutomatedTesting #DDEV #Drupal #Drupal8 #PHP
|
||||
EOF;
|
||||
|
||||
$this->assertSame($expected, $post->toTweet());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function certain_terms_are_not_added_as_hashtags(): void {
|
||||
$post = (new PostFactory())
|
||||
->setTitle('Drupal Planet should not be added as a hashtag')
|
||||
->withTags(['Drupal', 'Drupal Planet', 'PHP'])
|
||||
->create();
|
||||
|
||||
$post->save();
|
||||
|
||||
$expected = <<<EOF
|
||||
Drupal Planet should not be added as a hashtag
|
||||
|
||||
http://localhost/node/1
|
||||
|
||||
#Drupal #PHP
|
||||
EOF;
|
||||
|
||||
$this->assertSame($expected, $post->toTweet());
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
|
||||
$this->installConfig(['opdavies_blog_test']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\opdavies_blog\Kernel;
|
||||
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\taxonomy\TermInterface;
|
||||
use Drupal\taxonomy\VocabularyInterface;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
|
||||
|
||||
final class ReorderBlogTagsTest extends EntityKernelTestBase {
|
||||
|
||||
use NodeCreationTrait;
|
||||
use TaxonomyTestTrait;
|
||||
|
||||
public static $modules = [
|
||||
// Core.
|
||||
'node',
|
||||
'taxonomy',
|
||||
'link',
|
||||
|
||||
// Contrib.
|
||||
'discoverable_entity_bundle_classes',
|
||||
'hook_event_dispatcher',
|
||||
|
||||
// Custom.
|
||||
'opdavies_blog_test',
|
||||
'opdavies_blog',
|
||||
];
|
||||
|
||||
/** @test */
|
||||
public function it_reorders_tags_on_blog_posts_to_be_arranged_alphabetically(): void {
|
||||
/** @var VocabularyInterface $vocabulary */
|
||||
$vocabulary = Vocabulary::load('tags');
|
||||
|
||||
$this->createTerm($vocabulary, ['name' => 'Drupal']); // 1
|
||||
$this->createTerm($vocabulary, ['name' => 'PHP']); // 2
|
||||
$this->createTerm($vocabulary, ['name' => 'Symfony']); // 3
|
||||
|
||||
$post = $this->createNode([
|
||||
'field_tags' => [3, 1, 2],
|
||||
'type' => 'post',
|
||||
]);
|
||||
|
||||
/** @var Post $post */
|
||||
$post = Node::load($post->id());
|
||||
|
||||
$this->assertSame(
|
||||
['Drupal', 'PHP', 'Symfony'],
|
||||
$post->getTags()
|
||||
->map(fn(TermInterface $tag) => $tag->label())
|
||||
->toArray()
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig([
|
||||
'filter',
|
||||
'opdavies_blog_test',
|
||||
]);
|
||||
|
||||
$this->installEntitySchema('taxonomy_vocabulary');
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue