Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Hexagonal Maker Bundle Laravel Package

ahmed-bhs/hexagonal-maker-bundle

View on GitHub
Deep Wiki
Context7

layout: default title: Testing Guide parent: Examples nav_order: 3

Testing Examples

Examples of testing hexagonal architecture with generated tests.


Generate Tests

# With command
bin/console make:hexagonal:command blog/post create --with-tests

# Standalone
bin/console make:hexagonal:use-case-test blog/post CreatePost
bin/console make:hexagonal:controller-test blog/post CreatePost /posts/new

Unit Test Example

<?php

namespace Tests\Blog\Post\Application\Create;

use PHPUnit\Framework\TestCase;

final class CreatePostHandlerTest extends TestCase
{
    public function testCreatesPost(): void
    {
        $repository = $this->createMock(PostRepositoryInterface::class);
        $repository->expects($this->once())->method('save');

        $handler = new CreatePostHandler($repository);
        $command = new CreatePostCommand('Title', 'Content');

        $handler($command);
    }
}

Integration Test Example

<?php

namespace Tests\Blog\Post\Application\Create;

use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

final class CreatePostIntegrationTest extends KernelTestCase
{
    public function testCreatesPostInDatabase(): void
    {
        self::bootKernel();

        $commandBus = static::getContainer()->get(MessageBusInterface::class);
        $command = new CreatePostCommand('Title', 'Content');

        $commandBus->dispatch($command);

        $repository = static::getContainer()->get(PostRepositoryInterface::class);
        $posts = $repository->findAll();

        $this->assertCount(1, $posts);
    }
}

Run Tests

vendor/bin/phpunit

See generated test files for complete examples.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky