<commit_before><?php

namespace Ems\Events;

use Ems\Contracts\Core\Url as UrlContract;
use Ems\Contracts\Events\Bus as BusContract;
use Ems\Contracts\Events\Receiver;
use Ems\Contracts\Events\Signal;
use Ems\Contracts\Events\Slot;
use Ems\Contracts\Http\Client as ClientContract;
use Ems\Contracts\Events\Broadcaster;
use Ems\Core\Exceptions\KeyNotFoundException;
use Ems\Core\Url;
use Ems\Testing\LoggingCallable;


class RESTBroadcasterTest extends \Ems\TestCase
{

    /**
     * @var Url
     */
    protected $url;

    /**
     * @var Url
     */
    protected $remoteUrl;

    public function setUp()
    {
        parent::setUp();
        $this->url = new Url('https://web-utils.de/api/v1');
        $this->remoteUrl = new Url('https://tils.org/api/v1');
    }

    public function test_it_instantiates()
    {
        $this->assertInstanceOf(
            Broadcaster::class,
            $this->newBroadcaster()
        );
    }

    public function test_name_apiName_and_apiVersion()
    {
        $this->assertNotEmpty($this->newBroadcaster()->name());
        $this->assertNotEmpty($this->newBroadcaster()->apiName());
        $this->assertNotEmpty($this->newBroadcaster()->apiVersion());
    }

    public function test_add_custom_signalsUrl()
    {
        $broadcaster = $this->newBroadcaster()->setBaseUrl($this->url);

        $url = $this->url->append('foo');

        $broadcaster->setSignalsUrl($url);
        $this->assertSame($url, $broadcaster->getSignalsUrl());
    }

    /**
     * @expectedException \Ems\Contracts\Core\Errors\ConfigurationError
     */
    public function test_signalsUrl_throws_exception_if_no_url_setted()<commit_msg>Added small test for methodHooks()<commit_after><?php

namespace Ems\Events;

use Ems\Contracts\Core\Url as UrlContract;
use Ems\Contracts\Events\Bus as BusContract;
use Ems\Contracts\Events\Receiver;
use Ems\Contracts\Events\Signal;
use Ems\Contracts\Events\Slot;
use Ems\Contracts\Http\Client as ClientContract;
use Ems\Contracts\Events\Broadcaster;
use Ems\Core\Exceptions\KeyNotFoundException;
use Ems\Core\Url;
use Ems\Testing\LoggingCallable;


class RESTBroadcasterTest extends \Ems\TestCase
{

    /**
     * @var Url
     */
    protected $url;

    /**
     * @var Url
     */
    protected $remoteUrl;

    public function setUp()
    {
        parent::setUp();
        $this->url = new Url('https://web-utils.de/api/v1');
        $this->remoteUrl = new Url('https://tils.org/api/v1');
    }

    public function test_it_instantiates()
    {
        $this->assertInstanceOf(
            Broadcaster::class,
            $this->newBroadcaster()
        );
    }

    public function test_name_apiName_and_apiVersion()
    {
        $this->assertNotEmpty($this->newBroadcaster()->name());
        $this->assertNotEmpty($this->newBroadcaster()->apiName());
        $this->assertNotEmpty($this->newBroadcaster()->apiVersion());
    }

    public function test_add_custom_signalsUrl()
    {
        $broadcaster = $this->newBroadcaster()->setBaseUrl($this->url);

        $url = $this->url->append('foo');

        $broadcaster->setSignalsUrl($url);
        $this->assertSame($url, $broadcaster->getSignalsUrl());
        $this->assertEquals(['signalize', 'receive'], $broadcaster->methodHooks());
    }

    /**
     * @expectedException \Ems\Contracts\Core\Errors\ConfigurationError
     */
    public function test_signalsUrl_throws_exception_if_no_url_setted()
{'fraction_non_alphanumeric': 0.14477133702301195, 'fraction_numerical': 0.0011651616661811825, 'mean_word_length': 3.1076555023923444, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 4, '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': '240100', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1080, 'n_words': 162}