Skip to content

Commit 23f477e

Browse files
committed
test: correcting existing test files
1 parent f8c5682 commit 23f477e

File tree

5 files changed

+45
-41
lines changed

5 files changed

+45
-41
lines changed

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "alvincoded/grok-php-client",
3-
"description": "A robust and feature-rich 2-in-1 PHP SDK for the Grok AI API",
3+
"description": "A 2-in-1 PHP SDK to interact with the Grok AI API for both framework-agnostic PHP and Laravel applications",
44
"type": "library",
55
"license": "MIT",
66
"keywords": ["grok", "ai", "xai", "machine learning", "artificial intelligence", "laravel", "api", "sdk"],
@@ -39,8 +39,7 @@
3939
},
4040
"autoload-dev": {
4141
"psr-4": {
42-
"Tests\\": "tests/",
43-
"Tests\\Unit\\": "tests/Unit/"
42+
"Tests\\": "tests/"
4443
}
4544
},
4645
"scripts": {

src/Enums/Model.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,4 @@ public static function default(): self
125125
return self::GROK_2_1212;
126126
}
127127

128-
public function __toString(): string
129-
{
130-
return $this->value;
131-
}
132-
133128
}

tests/Unit/ProductInfo.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Tests\Unit;
4+
5+
use GrokPHP\Utils\DataModel;
6+
use GrokPHP\Utils\SchemaProperty;
7+
8+
class ProductInfo extends DataModel
9+
{
10+
#[SchemaProperty(type: 'string')]
11+
public string $productName;
12+
13+
#[SchemaProperty(type: 'string')]
14+
public string $manufacturer;
15+
16+
#[SchemaProperty(type: 'integer')]
17+
public int $releaseYear;
18+
19+
#[SchemaProperty(type: 'string', description: 'Screen size')]
20+
public string $screenSize;
21+
}

tests/Unit/StructuredOutput.php renamed to tests/Unit/StructuredOutputTest.php

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@
77
use GrokPHP\Client\GrokClient;
88
use GrokPHP\Enums\Model;
99
use GrokPHP\Exceptions\GrokException;
10-
use GrokPHP\Models\ChatMessage;
1110
use GrokPHP\Params;
12-
use GrokPHP\Utils\DataModel;
13-
use GrokPHP\Utils\SchemaProperty;
1411
use PHPUnit\Framework\TestCase;
1512

1613
class StructuredOutputTest extends TestCase
1714
{
15+
private string $apiKey = 'test-api-key';
1816
private GrokClient $client;
1917

2018
protected function setUp(): void
2119
{
22-
$this->client = new GrokClient($_ENV['API_KEY']);
20+
parent::setUp();
21+
$this->client = new GrokClient($this->apiKey);
2322
}
2423

2524
public function testArrayBasedStructuredOutput(): void
@@ -141,32 +140,4 @@ public function testStructuredOutputValidation(): void
141140
$this->fail('Expected response to be an object, got ' . gettype($response));
142141
}
143142
}
144-
}
145-
146-
// Test Data Models
147-
class UserData extends DataModel
148-
{
149-
#[SchemaProperty(type: 'string', description: 'Full name of user')]
150-
public string $name;
151-
152-
#[SchemaProperty(type: 'integer', description: 'Age in years')]
153-
public int $age;
154-
155-
#[SchemaProperty(type: 'string', required: false)]
156-
public ?string $email = null;
157-
}
158-
159-
class ProductInfo extends DataModel
160-
{
161-
#[SchemaProperty(type: 'string')]
162-
public string $productName;
163-
164-
#[SchemaProperty(type: 'string')]
165-
public string $manufacturer;
166-
167-
#[SchemaProperty(type: 'integer')]
168-
public int $releaseYear;
169-
170-
#[SchemaProperty(type: 'string', description: 'Screen size')]
171-
public string $screenSize;
172-
}
143+
}

tests/Unit/UserData.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Tests\Unit;
4+
5+
use GrokPHP\Utils\DataModel;
6+
use GrokPHP\Utils\SchemaProperty;
7+
8+
class UserData extends DataModel
9+
{
10+
#[SchemaProperty(type: 'string', description: 'Full name of user')]
11+
public string $name;
12+
13+
#[SchemaProperty(type: 'integer', description: 'Age in years')]
14+
public int $age;
15+
16+
#[SchemaProperty(type: 'string', required: false)]
17+
public ?string $email = null;
18+
}

0 commit comments

Comments
 (0)