<commit_before><?php

/*
 * This file is part of the overtrue/wechat.
 *
 * (c) overtrue <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace EasyWeChat\Tests\Work\Media;

use EasyWeChat\Tests\TestCase;
use EasyWeChat\Work\Media\Client;

class ClientTest extends TestCase
{
    public function testGet()
    {
        $client = $this->mockApiClient(Client::class);
        $client->expects()->httpGet('cgi-bin/media/get', ['media_id' => 'mock-media-id'])->andReturn('mock-result')->once();
        $this->assertSame('mock-result', $client->get('mock-media-id'));<commit_msg>Fix tests. #1165<commit_after><?php

/*
 * This file is part of the overtrue/wechat.
 *
 * (c) overtrue <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace EasyWeChat\Tests\Work\Media;

use EasyWeChat\Tests\TestCase;
use EasyWeChat\Work\Media\Client;
use EasyWeChat\Kernel\ServiceContainer;
use EasyWeChat\Kernel\Http\Response;
use EasyWeChat\Kernel\Http\StreamResponse;

class ClientTest extends TestCase
{
    public function testGet()
    {
        $app = new ServiceContainer();
        $client = $this->mockApiClient(Client::class, [], $app);

        $mediaId = 'invalid-media-id';
        $imageResponse = new Response(200, ['content-type' => 'text/plain'], '{"error": "invalid media id hits."}');
        $client->expects()->requestRaw('cgi-bin/media/get', 'GET', [
            'query' => [
                'media_id' => $mediaId,
            ],
        ])->andReturn($imageResponse)->once();

        $this->assertSame(['error' => 'invalid media id hits.'], $client->get($mediaId));

        $mediaId = 'valid-media-id';
        $imageResponse = new Response(200, [], 'valid data');
        $client->expects()->requestRaw('cgi-bin/media/get', 'GET', [
            'query' => [
                'media_id' => $mediaId,
            ],
        ])->andReturn($imageResponse)->once();

        $this->assertInstanceOf(StreamResponse::class, $client->get($mediaId));
{'fraction_non_alphanumeric': 0.16627302786962683, 'fraction_numerical': 0.004723665564478035, 'mean_word_length': 3.161100196463654, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5301975', 'n_tokens_mistral': 655, 'n_tokens_neox': 639, 'n_words': 147}