Removed useless method

pull/671/head
n0nag0n 15 hours ago
parent 009f2f9bad
commit e73b4e3f92

@ -9,14 +9,12 @@ use flight\commands\AiGenerateInstructionsCommand;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use tests\classes\NoExitInteractor; use tests\classes\NoExitInteractor;
class AiGenerateInstructionsCommandTest extends TestCase class AiGenerateInstructionsCommandTest extends TestCase {
{
protected static $in; protected static $in;
protected static $ou; protected static $ou;
protected $baseDir; protected $baseDir;
public function setUp(): void public function setUp(): void {
{
self::$in = __DIR__ . DIRECTORY_SEPARATOR . 'input.test' . uniqid('', true) . '.txt'; self::$in = __DIR__ . DIRECTORY_SEPARATOR . 'input.test' . uniqid('', true) . '.txt';
self::$ou = __DIR__ . DIRECTORY_SEPARATOR . 'output.test' . uniqid('', true) . '.txt'; self::$ou = __DIR__ . DIRECTORY_SEPARATOR . 'output.test' . uniqid('', true) . '.txt';
file_put_contents(self::$in, ''); file_put_contents(self::$in, '');
@ -27,8 +25,7 @@ class AiGenerateInstructionsCommandTest extends TestCase
} }
} }
public function tearDown(): void public function tearDown(): void {
{
if (file_exists(self::$in)) { if (file_exists(self::$in)) {
unlink(self::$in); unlink(self::$in);
} }
@ -38,8 +35,7 @@ class AiGenerateInstructionsCommandTest extends TestCase
$this->recursiveRmdir($this->baseDir); $this->recursiveRmdir($this->baseDir);
} }
protected function recursiveRmdir($dir) protected function recursiveRmdir($dir) {
{
if (!is_dir($dir)) { if (!is_dir($dir)) {
return; return;
} }
@ -50,8 +46,7 @@ class AiGenerateInstructionsCommandTest extends TestCase
return rmdir($dir); return rmdir($dir);
} }
protected function newApp($command): Application protected function newApp($command): Application {
{
$app = new Application('test', '0.0.1', function ($exitCode) { $app = new Application('test', '0.0.1', function ($exitCode) {
return $exitCode; return $exitCode;
}); });
@ -60,13 +55,11 @@ class AiGenerateInstructionsCommandTest extends TestCase
return $app; return $app;
} }
protected function setInput(array $lines): void protected function setInput(array $lines): void {
{
file_put_contents(self::$in, implode("\n", $lines) . "\n"); file_put_contents(self::$in, implode("\n", $lines) . "\n");
} }
protected function setProjectRoot($command, $path) protected function setProjectRoot($command, $path) {
{
$reflection = new \ReflectionClass(get_class($command)); $reflection = new \ReflectionClass(get_class($command));
$property = null; $property = null;
$currentClass = $reflection; $currentClass = $reflection;
@ -78,13 +71,11 @@ class AiGenerateInstructionsCommandTest extends TestCase
} }
} }
if ($property) { if ($property) {
$property->setAccessible(true);
$property->setValue($command, $path); $property->setValue($command, $path);
} }
} }
public function testFailsIfAiConfigMissing() public function testFailsIfAiConfigMissing() {
{
$this->setInput([ $this->setInput([
'desc', 'desc',
'none', 'none',
@ -112,8 +103,7 @@ class AiGenerateInstructionsCommandTest extends TestCase
$this->assertStringContainsString('Missing AI configuration', file_get_contents(self::$ou)); $this->assertStringContainsString('Missing AI configuration', file_get_contents(self::$ou));
} }
public function testWritesInstructionsToFiles() public function testWritesInstructionsToFiles() {
{
$creds = [ $creds = [
'api_key' => 'key', 'api_key' => 'key',
'model' => 'gpt-4o', 'model' => 'gpt-4o',
@ -160,8 +150,7 @@ class AiGenerateInstructionsCommandTest extends TestCase
$this->assertFileExists($this->baseDir . '.windsurfrules'); $this->assertFileExists($this->baseDir . '.windsurfrules');
} }
public function testNoInstructionsReturnedFromLlm() public function testNoInstructionsReturnedFromLlm() {
{
$creds = [ $creds = [
'api_key' => 'key', 'api_key' => 'key',
'model' => 'gpt-4o', 'model' => 'gpt-4o',
@ -203,8 +192,7 @@ class AiGenerateInstructionsCommandTest extends TestCase
$this->assertSame(1, $result); $this->assertSame(1, $result);
} }
public function testLlmApiCallFails() public function testLlmApiCallFails() {
{
$creds = [ $creds = [
'api_key' => 'key', 'api_key' => 'key',
'model' => 'gpt-4o', 'model' => 'gpt-4o',
@ -242,8 +230,7 @@ class AiGenerateInstructionsCommandTest extends TestCase
$this->assertSame(1, $result); $this->assertSame(1, $result);
} }
public function testUsesDeprecatedConfigFile() public function testUsesDeprecatedConfigFile() {
{
$creds = [ $creds = [
'ai' => [ 'ai' => [
'api_key' => 'key', 'api_key' => 'key',

Loading…
Cancel
Save