Skip to content

Commit

Permalink
Migrated to PhotoTestBase
Browse files Browse the repository at this point in the history
  • Loading branch information
nagmat84 committed Jul 24, 2022
1 parent ec96126 commit cde6d63
Showing 1 changed file with 14 additions and 44 deletions.
58 changes: 14 additions & 44 deletions tests/Feature/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,17 @@

namespace Tests\Feature;

use App\Facades\AccessControl;
use Tests\Feature\Lib\AlbumsUnitTest;
use Tests\Feature\Lib\PhotosUnitTest;
use Tests\Feature\Base\PhotoTestBase;
use Tests\TestCase;

class SearchTest extends TestCase
class SearchTest extends PhotoTestBase
{
public function testSearchPhotoByTitle(): void
{
AccessControl::log_as_id(0);

$photos_tests = new PhotosUnitTest($this);

$photoId = $photos_tests->upload(
$photoId = $this->photos_tests->upload(
TestCase::createUploadedFile(TestCase::SAMPLE_FILE_NIGHT_IMAGE)
);
$photos_tests->set_title($photoId, 'photo search');
)->offsetGet('id');
$this->photos_tests->set_title($photoId, 'photo search');

$response = $this->postJson(
'/api/Search::run',
Expand Down Expand Up @@ -62,28 +56,20 @@ public function testSearchPhotoByTitle(): void
'original' => [
'width' => 6720,
'height' => 4480,
'filesize' => 22842265,
'filesize' => 21106422,
],
],
],
],
]);

$photos_tests->delete([$photoId]);

AccessControl::logout();
}

public function testSearchPhotoByTag(): void
{
AccessControl::log_as_id(0);

$photos_tests = new PhotosUnitTest($this);

$photoId = $photos_tests->upload(
$photoId = $this->photos_tests->upload(
TestCase::createUploadedFile(TestCase::SAMPLE_FILE_NIGHT_IMAGE)
);
$photos_tests->set_tag([$photoId], ['search tag']);
)->offsetGet('id');
$this->photos_tests->set_tag([$photoId], ['search tag']);

$response = $this->postJson(
'/api/Search::run',
Expand Down Expand Up @@ -117,26 +103,18 @@ public function testSearchPhotoByTag(): void
'original' => [
'width' => 6720,
'height' => 4480,
'filesize' => 22842265,
'filesize' => 21106422,
],
],
],
],
]);

$photos_tests->delete([$photoId]);

AccessControl::logout();
}

public function testSearchAlbumByName(): void
{
AccessControl::log_as_id(0);

$albums_test = new AlbumsUnitTest($this);

/** @var string $id */
$id = $albums_test->add(null, 'search')->offsetGet('id');
$id = $this->albums_tests->add(null, 'search')->offsetGet('id');

$response = $this->postJson(
'/api/Search::run',
Expand All @@ -151,19 +129,13 @@ public function testSearchAlbumByName(): void
]],
]);

$albums_test->delete([$id]);

AccessControl::logout();
$this->albums_tests->delete([$id]);
}

public function testSearchAlbumByTag(): void
{
AccessControl::log_as_id(0);

$albums_test = new AlbumsUnitTest($this);

/** @var string $tagId */
$tagId = $albums_test->addByTags('tag search', ['tag1', 'tag2'])->offsetGet('id');
$tagId = $this->albums_tests->addByTags('tag search', ['tag1', 'tag2'])->offsetGet('id');

$response = $this->postJson(
'/api/Search::run',
Expand All @@ -180,8 +152,6 @@ public function testSearchAlbumByTag(): void
],
]);

$albums_test->delete([$tagId]);

AccessControl::logout();
$this->albums_tests->delete([$tagId]);
}
}

0 comments on commit cde6d63

Please sign in to comment.