1. Go to this page and download the library: Download ablogcms/testing-framework library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ablogcms / testing-framework example snippets
// tests/bootstrap.php(カスタムが必要なときだけ)
namespace Acms\Plugins\Foo\Tests\Unit;
use Acms\Plugins\Foo\Services\Foo\Helper;
use Acms\TestingFramework\TestCase;
use PHPUnit\Framework\Attributes\Test;
final class HelperTest extends TestCase
{
#[Test]
public function 先頭にアットマークを付与する(): void
{
$this->assertSame('@appleple', (new Helper())->formatHandle('appleple'));
}
}
namespace Acms\Plugins\Foo\Tests\Integration;
use Acms\Plugins\Foo\Services\Foo\UserMapper;
use Acms\TestingFramework\DatabaseTestCase;
use Acms\TestingFramework\Seeder\UserSeeder;
use PHPUnit\Framework\Attributes\Test;
final class UserMapperTest extends DatabaseTestCase
{
private int $blogId;
protected function setUpDatabase(): void
{
$this->blogId = $this->createTestBlog(['blog_name' => 'テストブログ']);
}
#[Test]
public function メールで有効ユーザーを特定する(): void
{
$userId = UserSeeder::seed($this->blogId, ['user_mail' => '[email protected]']);
$result = (new UserMapper($this->blogId))->resolve('[email protected]');
$this->assertSame($userId, $result['userId']);
}
}