Skip to content

Commit

Permalink
Remove deprecated methods in tests (#33)
Browse files Browse the repository at this point in the history
* Remove deprecated methods in tests

* WIP
  • Loading branch information
mako321 authored Feb 16, 2024
1 parent 8bcc382 commit 8dde49c
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/API/TagsApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace EscolaLms\Tags\Tests\API;

use Config;
use EscolaLms\Courses\Models\Course;
use EscolaLms\Tags\Models\Tag;
use EscolaLms\Tags\Tests\TestCase;
use EscolaLms\Tags\Database\Seeders\TagsPermissionSeeder;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Config;

class TagsApiTest extends TestCase
{
Expand All @@ -32,10 +31,12 @@ public function testTagsInsert() : void
'tags' => [
['title' => 'test'],
]
]);
$this->assertObjectHasAttribute('data', $response->getData());
$this->assertIsArray($response->getData()->data);
$this->assertTrue($response->getData()->data[0]->title === 'test');
])
->assertOk()
->assertJsonCount(1, 'data')
->assertJsonFragment([
'title' => 'test',
]);
}

public function testTagsIndex() : void
Expand All @@ -61,9 +62,9 @@ public function testTagShow() : void
]);
$tags = $response->getData()->data;
$response = $this->json('GET', '/api/admin/tags/' . $tags[0]->id);
$this->assertObjectHasAttribute('data', $response->getData());
$response->assertOk();
$this->assertIsObject($response->getData()->data);
$this->assertTrue($response->getData()->data->id === $tags[0]->id);
$response->assertJsonPath('data.id', $tags[0]->id);
}

public function testTagDestroy() : void
Expand Down Expand Up @@ -97,9 +98,9 @@ public function testTagDestroy() : void

public function testTagsUnique() : void
{
$response = $this->json('GET', '/api/tags/unique');
$response->assertStatus(200);
$this->assertObjectHasAttribute('data', $response->getData());
$response = $this->json('GET', '/api/tags/unique')
->assertOk();

$temp_array = $key_array = [];
foreach ($response->getData()->data as $key => $val) {
if (!in_array($val->title, $key_array)) {
Expand All @@ -112,9 +113,9 @@ public function testTagsUnique() : void

public function testTagsUniqueAdmin() : void
{
$response = $this->json('GET', '/api/admin/tags/unique');
$response->assertStatus(200);
$this->assertObjectHasAttribute('data', $response->getData());
$response = $this->json('GET', '/api/admin/tags/unique')
->assertOk();

$temp_array = $key_array = [];
foreach ($response->getData()->data as $key => $val) {
if (!in_array($val->title, $key_array)) {
Expand Down

0 comments on commit 8dde49c

Please sign in to comment.