<commit_before><?php

use Mockery as m;
use Raideer\TwitchApi\Resources\Channels;

class ChannelsTest extends PHPUnit_Framework_TestCase
{
    protected $wrapper;
    protected $resource;

    protected function setUp()
    {
        $this->wrapper = m::mock("Raideer\TwitchApi\Wrapper");
        $this->wrapper->shouldReceive('registerResource')->with('Raideer\TwitchApi\Resources\Resource');
        $this->resource = new Channels($this->wrapper);
    }

    public function test_getName_returnsChannels()
    {
        $resource = $this->resource;

        $this->assertSame('channels', $resource->getName());
    }

    public function test_getChannel()
    {
        $this->wrapper->shouldReceive('checkScope')->with('channel_read');
        $this->wrapper->shouldReceive('request')->withArgs([
          'GET',
          'channel',
          [],
          true,
        ]);

        $resource = $this->resource;
        $resource->getChannel();
    }

    public function test_getChannelName()
    {
        $this->wrapper->shouldReceive('checkScope')->with('channel_read');
        $this->wrapper->shouldReceive('request')->withArgs([
          'GET',
          'channel/testchannel',
          [],
          true,
        ]);

        $resource = $this->resource;
        $resource->getChannel('testchannel');
    }

    public function test_getEditors()
    {
        $this->wrapper->shouldReceive('checkScope')->with('channel_read');
        $this->wrapper->shouldReceive('request')->withArgs([
          'GET',
          'channels/testchannel/editors',
          [],
          true,
        ]);

        $resource = $this->resource;
        $resource->getEditors('testchannel');
    }

    public function test_updateChannel()
    {
        $this->wrapper->shouldReceive('checkScope')->with('channel_editor');
        $this->wrapper->shouldReceive('request')->withArgs([
          'PUT',
          'channels/testchannel',
          ['form_params' => ['status' => 'hello', 'game' => 'Rust']],
          true,
        ]);

        $resource = $this->resource;
        $resource->updateChannel('testchannel', ['status' => 'hello', 'game' => 'Rust']);
    }
}<commit_msg>Using the custom test case<commit_after><?php

use Mockery as m;

class ChannelsTest extends Raideer\TwitchApi\TestCase
{
    public function __construct()
    {
        $this->setResource("Raideer\TwitchApi\Resources\Channels");
    }

    public function test_getName_returnsChannels()
    {
        $resource = $this->resource;

        $this->assertSame('channels', $resource->getName());
    }

    public function test_getChannel()
    {
        $this->checkForScope('channel_read');

        $this->mockRequest(
            $this->wrapper,
            'GET',
            'channel',
            [],
            true
        );

        $resource = $this->resource;
        $resource->getChannel();
    }

    public function test_getChannelName()
    {
        $this->mockRequest(
            $this->wrapper,
            'GET',
            'channels/testchannel'
        );

        $resource = $this->resource;
        $resource->getChannel('testchannel');
    }

    public function test_getEditors()
    {
        $this->checkForScope('channel_read');

        $this->mockRequest(
            $this->wrapper,
            'GET',
            'channels/testchannel/editors',
            [],
            true
        );

        $resource = $this->resource;
        $resource->getEditors('testchannel');
    }

    public function test_updateChannel()
    {
        $this->checkForScope('channel_editor');

        $this->mockRequest(
            $this->wrapper,
            'PUT',
            'channels/testchannel',
            ['channel' => ['status' => 'hello', 'game' => 'Rust']],
            true
        );

        $resource = $this->resource;
        $resource->updateChannel('testchannel', ['status' => 'hello', 'game' => 'Rust']);
    }
}
{'fraction_non_alphanumeric': 0.1569175991861648, 'fraction_numerical': 0.0, 'mean_word_length': 2.1666666666666665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 77, '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': '950962', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1071, 'n_words': 163}