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

Laravel Cycle Orm Adapter Laravel Package

wayofdev/laravel-cycle-orm-adapter

View on GitHub
Deep Wiki
Context7

import {Callout} from "nextra-theme-docs"; import ExternalLink from "../../components/external-link";

Testing

Adapter package provides a set of modified Laravel testing traits and methods to make testing easier, and as close as possible to native Laravel Testing methods, when using CycleORM.

🗑️ Resetting the Database After Each Test

@todo This trait is not yet implemented as native adapter functionality.

Currently, you can use default Illuminate\Foundation\Testing\RefreshDatabase trait to reset the database after each test. It will use the default Laravel database connection to reset the database.

🏭 Entity Factories

When testing, you may need to insert a few records into your database before executing your test. Instead of manually specifying the value of each column when you create this test data, Adapter package allows you to define a set of default attributes for each of your CycleORM Entities using Entity Factories.

Once you have defined an entity factory, you may utilize the factory within your test to create entities:

use Database\Factories\Post\PostFactory;

/**
 * [@test](https://github.com/test)
 */
public function it_creates_post_entity_and_persists_it(): void
{
    $post = PostFactory::new()->create();

    // ...
}

👟 Running Seeders

If you would like to use database seeders to populate your database during a feature test, you may invoke the seed method. By default, the seed method will execute the DatabaseSeeder, which should execute all of your other seeders. Alternatively, you pass a specific seeder class name to the seed method:

<?php

declare(strict_types=1);

namespace Tests\Feature;

use Database\Seeders\Post\PostSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class ExampleTest extends TestCase
{
    use RefreshDatabase;

    /**
     * [@test](https://github.com/test)
     */
    public function it_can_seed_posts(): void
    {
        // Run the DatabaseSeeder...
        $this->seed();

        // Run a specific seeder...
        $this->seed(PostSeeder::class);

        // ...

        // Run an array of specific seeders...
        $this->seed([
            OrderStatusSeeder::class,
            TransactionStatusSeeder::class,
            // ...
        ]);
    }
}

🔍 Available Assertions

This adapter package overrides Laravel's assertion methods to make them work with CycleORM entities. Use WayOfDev\Cycle\Testing\Concerns\InteractsWithDatabase trait in your base test case or in test cases where it is needed, instead of default Laravel InteractsWithDatabase trait.

assertDatabaseCount

Assert that a table in the database contains the given number of records:

$this->assertDatabaseCount('posts', 1);

assertDatabaseHas

Assert that a table in the database contains records matching the given key / value query constraints:

$this->assertDatabaseHas('posts', [
    'id' => $response->json('id'),
    'title' => 'New Post'
]);

assertDatabaseMissing

Assert that a table in the database does not contain records matching the given key / value query constraints:

$this->assertDatabaseMissing('posts', [
    'id' => $response->json('id'),
    'title' => 'New Post'
]);

assertSoftDeleted

Assert that a given entity has been soft-deleted:

$this->assertSoftDeleted('posts', [
    'id' => $post->id
]);

assertNotSoftDeleted

Opposite to assertSoftDeleted method. Assert that a given entity has not been soft-deleted:

$this->assertNotSoftDeleted('posts', [
    'id' => $post->id
]);
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
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