Skip to content

Commit b6b0cb6

Browse files
committed
fix tests and ci
1 parent d945a2a commit b6b0cb6

File tree

5 files changed

+35
-34
lines changed

5 files changed

+35
-34
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ jobs:
2222
- name: Copy environment file
2323
run: cp app-laravel/api-laravel/.env.example app-laravel/api-laravel/.env
2424

25-
- name: Install Composer dependencies
26-
working-directory: app-laravel/api-laravel
27-
run: composer install --prefer-dist --no-progress --no-interaction
28-
29-
- name: Generate application key
30-
working-directory: app-laravel/api-laravel
31-
run: php artisan key:generate
32-
3325
- name: Create storage directories
3426
working-directory: app-laravel/api-laravel
3527
run: |
@@ -39,6 +31,14 @@ jobs:
3931
mkdir -p storage/framework/views
4032
chmod -R 775 storage
4133
34+
- name: Install Composer dependencies
35+
working-directory: app-laravel/api-laravel
36+
run: composer install --prefer-dist --no-progress --no-interaction
37+
38+
- name: Generate application key
39+
working-directory: app-laravel/api-laravel
40+
run: php artisan key:generate
41+
4242
- name: Run tests
4343
working-directory: app-laravel/api-laravel
4444
run: ./vendor/bin/phpunit --testdox

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ app-laravel/api-laravel/public/robots.txt
2828
app-laravel/api-laravel/public/packages/chat/
2929
app-laravel/api-laravel/public/mix-manifest.json
3030
app-laravel/api-laravel/public/yandex_*
31+
app-laravel/api-laravel/.phpunit.cache/*
3132

3233
data/db/mysql/db_data
3334
data/db/pg/db_data
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
55
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
96
processIsolation="false"
10-
stopOnFailure="false">
7+
stopOnFailure="false"
8+
cacheDirectory=".phpunit.cache"
9+
backupStaticProperties="false">
1110
<testsuites>
1211
<testsuite name="Unit">
1312
<directory suffix="Test.php">./tests/Unit</directory>
1413
</testsuite>
15-
1614
<testsuite name="Feature">
1715
<directory suffix="Test.php">./tests/Feature</directory>
1816
</testsuite>
1917
</testsuites>
20-
<filter>
21-
<whitelist processUncoveredFilesFromWhitelist="true">
18+
<source>
19+
<include>
2220
<directory suffix=".php">./app</directory>
23-
</whitelist>
24-
</filter>
21+
</include>
22+
</source>
2523
<php>
2624
<env name="APP_ENV" value="testing"/>
2725
<env name="BCRYPT_ROUNDS" value="4"/>
@@ -32,4 +30,4 @@
3230
<env name="DB_CONNECTION" value="sqlite"/>
3331
<env name="DB_DATABASE" value=":memory:"/>
3432
</php>
35-
</phpunit>
33+
</phpunit>

app-laravel/api-laravel/tests/Feature/AdminPostsTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Foundation\Testing\RefreshDatabase;
1111
use Illuminate\Http\UploadedFile;
1212
use Illuminate\Support\Facades\Storage;
13+
use PHPUnit\Framework\Attributes\Test;
1314
use Tests\TestCase;
1415

1516
class AdminPostsTest extends TestCase
@@ -20,7 +21,7 @@ class AdminPostsTest extends TestCase
2021
private Category $category;
2122
private Tag $tag;
2223

23-
/** @test */
24+
#[Test]
2425
public function admin_can_create_post()
2526
{
2627
$postData = [
@@ -53,7 +54,7 @@ public function admin_can_create_post()
5354
$this->assertTrue($post->tags->contains($this->tag));
5455
}
5556

56-
/** @test */
57+
#[Test]
5758
public function admin_can_create_post_with_image()
5859
{
5960
$image = UploadedFile::fake()->image('test.jpg');
@@ -84,7 +85,7 @@ public function admin_can_create_post_with_image()
8485
$this->assertNotNull($post->image);
8586
}
8687

87-
/** @test */
88+
#[Test]
8889
public function guest_cannot_create_post()
8990
{
9091
$postData = [
@@ -100,7 +101,7 @@ public function guest_cannot_create_post()
100101
$response->assertStatus(404); // Route не найден без middleware
101102
}
102103

103-
/** @test */
104+
#[Test]
104105
public function non_admin_cannot_create_post()
105106
{
106107
$user = User::factory()->create(['is_admin' => false]);
@@ -119,7 +120,7 @@ public function non_admin_cannot_create_post()
119120
$response->assertStatus(404); // Route не найден без admin middleware
120121
}
121122

122-
/** @test */
123+
#[Test]
123124
public function create_post_validates_required_fields()
124125
{
125126
$response = $this->actingAs($this->adminUser)
@@ -129,7 +130,7 @@ public function create_post_validates_required_fields()
129130
$response->assertSessionHasErrors(['title', 'content', 'date']);
130131
}
131132

132-
/** @test */
133+
#[Test]
133134
public function create_post_validates_image_type()
134135
{
135136
$file = UploadedFile::fake()->create('document.pdf', 1000);

app-laravel/api-laravel/tests/Feature/PostDateTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Models\Tag;
88
use App\Models\User;
99
use Illuminate\Foundation\Testing\RefreshDatabase;
10+
use PHPUnit\Framework\Attributes\Test;
1011
use Tests\TestCase;
1112

1213
class PostDateTest extends TestCase
@@ -17,7 +18,7 @@ class PostDateTest extends TestCase
1718
private Category $category;
1819
private Tag $tag;
1920

20-
/** @test */
21+
#[Test]
2122
public function post_can_save_date_in_y_m_d_format()
2223
{
2324
$postData = [
@@ -46,7 +47,7 @@ public function post_can_save_date_in_y_m_d_format()
4647
$this->assertEquals('2025-01-15', $post->date);
4748
}
4849

49-
/** @test */
50+
#[Test]
5051
public function post_can_update_date_in_y_m_d_format()
5152
{
5253
$post = Post::factory()->create([
@@ -83,7 +84,7 @@ public function post_can_update_date_in_y_m_d_format()
8384
$this->assertEquals('2025-02-20', $post->date);
8485
}
8586

86-
/** @test */
87+
#[Test]
8788
public function post_date_mutator_handles_empty_date()
8889
{
8990
$post = new Post();
@@ -92,7 +93,7 @@ public function post_date_mutator_handles_empty_date()
9293
$this->assertNull($post->getAttributes()['date']);
9394
}
9495

95-
/** @test */
96+
#[Test]
9697
public function post_date_mutator_handles_null_date()
9798
{
9899
$post = new Post();
@@ -101,7 +102,7 @@ public function post_date_mutator_handles_null_date()
101102
$this->assertNull($post->getAttributes()['date']);
102103
}
103104

104-
/** @test */
105+
#[Test]
105106
public function post_date_mutator_converts_valid_date()
106107
{
107108
$post = new Post();
@@ -110,7 +111,7 @@ public function post_date_mutator_converts_valid_date()
110111
$this->assertEquals('2025-01-15', $post->getAttributes()['date']);
111112
}
112113

113-
/** @test */
114+
#[Test]
114115
public function post_date_accessor_returns_saved_date()
115116
{
116117
$post = Post::factory()->create([
@@ -122,7 +123,7 @@ public function post_date_accessor_returns_saved_date()
122123
$this->assertEquals('2025-01-15', $post->date);
123124
}
124125

125-
/** @test */
126+
#[Test]
126127
public function post_date_accessor_returns_null_for_empty_date()
127128
{
128129
$post = Post::factory()->create([
@@ -134,7 +135,7 @@ public function post_date_accessor_returns_null_for_empty_date()
134135
$this->assertNull($post->date);
135136
}
136137

137-
/** @test */
138+
#[Test]
138139
public function debug_post_creation_with_specific_date()
139140
{
140141
$testDate = '2025-07-06';

0 commit comments

Comments
 (0)