Files
Woles-Framework/tests/TestCase.php

66 lines
1.4 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Tests;
use PHPUnit\Framework\TestCase as BaseTestCase;
use App\Core\Bootstrap;
use App\Core\Container;
/**
* Base test case for NovaCore Framework
*/
abstract class TestCase extends BaseTestCase
{
protected ?Container $container = null;
protected ?Bootstrap $bootstrap = null;
protected function setUp(): void
{
parent::setUp();
// Set up test environment
putenv('APP_ENV=testing');
putenv('APP_DEBUG=true');
// Initialize container and bootstrap
$this->container = new Container();
$this->bootstrap = new Bootstrap();
}
protected function tearDown(): void
{
parent::tearDown();
// Clean up
$this->container = null;
$this->bootstrap = null;
}
/**
* Create a test request
*/
protected function createRequest(array $data = [], string $method = 'GET'): void
{
$_SERVER['REQUEST_METHOD'] = $method;
$_GET = $data;
$_POST = $method === 'POST' ? $data : [];
$_REQUEST = array_merge($_GET, $_POST);
}
/**
* Assert that response contains text
*/
protected function assertResponseContains(string $content, string $text): void
{
$this->assertStringContainsString($text, $content);
}
/**
* Assert that response is JSON
*/
protected function assertJsonResponse(string $content): void
{
$this->assertJson($content);
}
}