<?php

namespace Frontend\Modules\Profiles\Tests\Engine;

use Frontend\Modules\Profiles\Engine\Model;
use Common\WebTestCase;
use Frontend\Modules\Profiles\Engine\Profile;

final class ModelTest extends WebTestCase
{
    public function setUp(): void
    {
        parent::setUp();

        if (!defined('APPLICATION')) {
            define('APPLICATION', 'Frontend');
        }

        $client = self::createClient();
        $this->loadFixtures($client);
    }

    public function testInsertingProfile(): void
    {
        $profileId = $this->addProfile();

        $profileData = $this->getProfileData();
        $addedProfile = Model::get($profileId);

        $this->assertInstanceOf(Profile::class, $addedProfile);

        $this->assertEquals($profileId, $addedProfile->getId());
        $this->assertEquals($profileData['email'], $addedProfile->getEmail());
        $this->assertEquals($profileData['status'], $addedProfile->getStatus());
        $this->assertEquals($profileData['display_name'], $addedProfile->getDisplayName());
        $this->assertEquals($profileData['url'], $addedProfile->getUrl());

        $this->assertEquals($profileId, Model::getIdByEmail($profileData['email']));
    }

    public function addProfile(): int
    {
        return Model::insert($this->getProfileData());
    }

    public function getProfileData(): array
    {
        return [
            'email' => 'test@fork-cms.com',
            'password' => '$2y$10$1Ev9QQNYZBjdU1ELKjKNqelcV.j2l3CgtVkHl0aMvbNpg1g73S5lC',
            'status' => 'active',
            'display_name' => 'Fork CMS',
            'url' => 'fork-cms',
            'registered_on' => '2018-03-05 09:45:12',
            'last_login' => '1970-01-01 00:00:00',
        ];
    }
}

Test adding a profile in the frontend
Test adding a profile in the frontend
