frknasir's avatar

Method Illuminate\Database\SQLiteConnection::isMaria does not exist.

Any knows why I might getting this error while running tests in my Laravel application using Pest framework. I am using sqlite db instead of mysql. All other tests are working except the ones that involve me creating models with this two factories:

EntityFactory.php

<?php

namespace Database\Factories;

use App\Models\Address;
use App\Models\Entity;
use Illuminate\Database\Eloquent\Factories\Factory;
use StarfolkSoftware\Pigeonhole\Pigeonhole;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Entity>
 */
class EntityFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = Entity::class;

    /**
     * Configure the model factory.
     *
     * @return $this
     */
    public function configure()
    {
        return $this->afterCreating(function (Entity $entity) {
            $categories = [Pigeonhole::newCategoryModel()->ofType('entity')->pluck('id')->random()];
            $entity->attachCategories($categories);

            $entity->addresses()->createMany(Address::factory()->count(rand(1, 5))->raw());
        });
    }

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition()
    {
        return [
            'slug' => $this->faker->unique()->slug,
            'name' => $this->faker->company,
            'description' => collect($this->faker->paragraphs(rand(2, 3)))->implode(fn ($paragraph) => "<p>{$paragraph}</p>"),
            'meta' => [],
        ];
    }
}

AddressFactory.php

<?php

namespace Database\Factories;

use App\Models\Address;
use Illuminate\Database\Eloquent\Factories\Factory;
use MatanYadaev\EloquentSpatial\Objects\Point;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Address>
 */
class AddressFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = Address::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition()
    {
        $coordinates = [
            [9.073535, 7.476154],
            [9.072281, 7.475393],
            [9.075458, 7.478051],
            [9.076731, 7.477227],
            [9.077005, 7.477595],
            [9.078249, 7.479964],
            [9.079623, 7.480004],
            [9.075771, 7.476607],
            [9.078395, 7.479227],
            [9.078910, 7.480556],
            [9.078890, 7.477868],
            [9.074479, 7.476396],
            [9.076018, 7.479340],
            [9.076319, 7.478667],
            [9.076542, 7.478304],
            [9.076573, 7.478675],
        ];

        return [
            'country_code' => 'ng',
            'state' => $this->faker->state,
            'postal_code' => $this->faker->postcode,
            'city' => $this->faker->city,
            'street' => $this->faker->streetAddress,
            'position' => new Point(
                (float) collect($coordinates)->random()[0],
                (float) collect($coordinates)->random()[1]
            ),
            'meta' => [
                'keywords' => $this->faker->words(3, true),
                'phone_number' => $this->faker->phoneNumber,
                'email' => $this->faker->email,
                'hours' => $this->faker->sentence,
                'links' => [
                    [
                        'name' => 'Website',
                        'url' => $this->faker->url,
                    ],
                    [
                        'name' => 'Facebook',
                        'url' => $this->faker->url,
                    ],
                    [
                        'name' => 'Twitter',
                        'url' => $this->faker->url,
                    ]
                ]
            ],
        ];
    }
}
0 likes
6 replies

Please or to participate in this conversation.