Skip to content

Commit

Permalink
test: Add feature test for SearchPosts functionality (q)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahmal1yev committed Dec 6, 2024
1 parent 5f56489 commit 8fe69b6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/Feature/Lexicons/App/Bsky/Feed/SearchPostsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Tests\Feature\Lexicons\App\Bsky\Feed;

use Atproto\Client;
use Atproto\Support\Arr;
use PHPUnit\Framework\TestCase;

class SearchPostsTest extends TestCase
{
private static Client $client;

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

static::$client = new Client();

static::$client->authenticate(
getenv('BLUESKY_IDENTIFIER'),
getenv('BLUESKY_PASSWORD')
);
}

/**
* @see https://bsky.app/profile/shahmal1yevv.bsky.social/post/3lccmota7wa23
*/
public function testSearchPostsWith(): void
{
$postContent = 'Hello World! This post was sent from a feature test of the BlueSky PHP SDK. You can read the docs from here. Author? Yes, @here it is. #php #sdk #bluesky';
$limit = 1;

$foundPosts = static::$client->app()->bsky()->feed()->searchPosts()->forge($postContent)
->limit($limit)
->send();

$this->assertSame($limit, $foundPosts->posts()->count());
$this->assertSame($postContent, Arr::get($foundPosts->posts()->get(0)->record(), 'text'));
}
}

0 comments on commit 8fe69b6

Please sign in to comment.