<commit_before><?php

/*
 * This file is part of the ripple library.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace jamband\ripple\tests;

use Goutte\Client;
use jamband\ripple\Ripple;

class RippleTest extends \PHPUnit_Framework_TestCase
{
    use ClientTrait;

    const TRACK_BANDCAMP = 'https://example.bandcamp.com/track/title';
    const EMBED_BANDCAMP = 'https://bandcamp.com/EmbeddedPlayer/track=';

    const TRACK_SOUNDCLOUD = 'https://soundcloud.com/example/title';
    const EMBED_SOUNDCLOUD = 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/';

    const TRACK_YOUTUBE = 'https://www.youtube.com/watch?v=AbCxYz012_';
    const EMBED_YOUTUBE = 'https://www.youtube.com/embed/';

    const TRACK_VIMEO = 'https://vimeo.com/1234567890';
    const EMBED_VIMEO = 'https://player.vimeo.com/video/';

    const TRACK_UNKNOWN_PROVIDER = 'https://www.example.com/';

    /**
     * @dataProvider constructProvider
     */
    public function testConstruct($url, $provider)
    {
        $ripple = new Ripple($url);
        $this->assertSame($provider, $ripple->provider);
    }

    public function constructProvider()
    {
        return [
            ['', null],
            [self::TRACK_UNKNOWN_PROVIDER, null],
            [self::TRACK_BANDCAMP, 'Bandcamp'],
            [self::TRACK_SOUNDCLOUD, 'SoundCloud'],
            [self::TRACK_VIMEO, 'Vimeo'],
            [self::TRACK_YOUTUBE, 'YouTube'],
        ];
    }

    /**
     * @dataProvider requestProvider
     */
    public function testRequest($provider, $track, $class)
    {
        $client = new Client();
        $client->setClient($this->getGuzzle(require __DIR__."/response/$provider.php"));

        $ripple = new Ripple($track);
        $ripple->request($client);
        // $this->assertInstanceOf($class, $ripple->content);
    }

    public function requestProvider()
    {
        return [
            ['YouTube', self::TRACK_YOUTUBE, 'stdClass'],
            ['Vimeo', self::TRACK_VIMEO, 'stdClass'],
            ['SoundCloud', self::TRACK_SOUNDCLOUD, 'Symfony\Component\DomCrawler\Crawler'],
            ['Bandcamp', self::TRACK_BANDCAMP, 'Symfony\Component\DomCrawler\Crawler'],
        ];
    }

    /**
     * @dataProvider embedProvider
     */
    public function testEmbed($file, $url, $embed)
    {
        $client = new Client();
        $client->setClient($this->getGuzzle(require __DIR__."/response/$file.php"));

        $ripple = new Ripple($url);
        $ripple->request($client);

        $this->assertSame($embed, $ripple->embed());
    }

    public function embedProvider()
    {
        return [
            ['UnknownProvider', self::TRACK_UNKNOWN_PROVIDER, null],
            ['YouTube', self::TRACK_YOUTUBE, self::EMBED_YOUTUBE.'AbCxYz012_'],
            ['Vimeo', self::TRACK_VIMEO, self::EMBED_VIMEO.'1234567890'],
            ['SoundCloud', self::TRACK_SOUNDCLOUD, self::EMBED_SOUNDCLOUD.'1234567890'],
            ['Bandcamp', self::TRACK_BANDCAMP, self::EMBED_BANDCAMP.'1234567890/'],
        ];
    }

    /**
     * @dataProvider setEmbedParamsWithoutSetParametersProvider
     */
    public function testSetEmbedParamsWithoutSetParameters($provider, $id, $embed)
    {
        $this->assertSame($embed, (new Ripple())->embed($provider, $id));
    }

    public function setEmbedParamsWithoutSetParametersProvider()
    {
        return [
            ['UnknownProvider', '1234567890', null],
            ['YouTube', 'AbCxYz012_', self::EMBED_YOUTUBE.'AbCxYz012_'],
            ['Vimeo', '1234567890', self::EMBED_VIMEO.'1234567890'],
            ['SoundCloud', '1234567890', self::EMBED_SOUNDCLOUD.'1234567890'],
            ['Bandcamp', '1234567890', self::EMBED_BANDCAMP.'1234567890/'],
        ];
    }

    /**
     * @dataProvider setEmbedParamsProvider
     */
    public function testSetEmbedParams($params, $provider, $id, $embed)
    {
        $ripple = new Ripple();
        $ripple->setEmbedParams($params);<commit_msg>Change some test case name<commit_after><?php

/*
 * This file is part of the ripple library.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace jamband\ripple\tests;

use Goutte\Client;
use jamband\ripple\Ripple;

class RippleTest extends \PHPUnit_Framework_TestCase
{
    use ClientTrait;

    const TRACK_BANDCAMP = 'https://example.bandcamp.com/track/title';
    const EMBED_BANDCAMP = 'https://bandcamp.com/EmbeddedPlayer/track=';

    const TRACK_SOUNDCLOUD = 'https://soundcloud.com/example/title';
    const EMBED_SOUNDCLOUD = 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/';

    const TRACK_YOUTUBE = 'https://www.youtube.com/watch?v=AbCxYz012_';
    const EMBED_YOUTUBE = 'https://www.youtube.com/embed/';

    const TRACK_VIMEO = 'https://vimeo.com/1234567890';
    const EMBED_VIMEO = 'https://player.vimeo.com/video/';

    const TRACK_UNKNOWN_PROVIDER = 'https://www.example.com/';

    /**
     * @dataProvider constructProvider
     */
    public function testConstruct($url, $provider)
    {
        $ripple = new Ripple($url);
        $this->assertSame($provider, $ripple->provider);
    }

    public function constructProvider()
    {
        return [
            ['', null],
            [self::TRACK_UNKNOWN_PROVIDER, null],
            [self::TRACK_BANDCAMP, 'Bandcamp'],
            [self::TRACK_SOUNDCLOUD, 'SoundCloud'],
            [self::TRACK_VIMEO, 'Vimeo'],
            [self::TRACK_YOUTUBE, 'YouTube'],
        ];
    }

    /**
     * @dataProvider requestProvider
     */
    public function testRequest($provider, $track, $class)
    {
        $client = new Client();
        $client->setClient($this->getGuzzle(require __DIR__."/response/$provider.php"));

        $ripple = new Ripple($track);
        $ripple->request($client);
        // $this->assertInstanceOf($class, $ripple->content);
    }

    public function requestProvider()
    {
        return [
            ['YouTube', self::TRACK_YOUTUBE, 'stdClass'],
            ['Vimeo', self::TRACK_VIMEO, 'stdClass'],
            ['SoundCloud', self::TRACK_SOUNDCLOUD, 'Symfony\Component\DomCrawler\Crawler'],
            ['Bandcamp', self::TRACK_BANDCAMP, 'Symfony\Component\DomCrawler\Crawler'],
        ];
    }

    /**
     * @dataProvider embedProvider
     */
    public function testEmbed($file, $url, $embed)
    {
        $client = new Client();
        $client->setClient($this->getGuzzle(require __DIR__."/response/$file.php"));

        $ripple = new Ripple($url);
        $ripple->request($client);

        $this->assertSame($embed, $ripple->embed());
    }

    public function embedProvider()
    {
        return [
            ['UnknownProvider', self::TRACK_UNKNOWN_PROVIDER, null],
            ['YouTube', self::TRACK_YOUTUBE, self::EMBED_YOUTUBE.'AbCxYz012_'],
            ['Vimeo', self::TRACK_VIMEO, self::EMBED_VIMEO.'1234567890'],
            ['SoundCloud', self::TRACK_SOUNDCLOUD, self::EMBED_SOUNDCLOUD.'1234567890'],
            ['Bandcamp', self::TRACK_BANDCAMP, self::EMBED_BANDCAMP.'1234567890/'],
        ];
    }

    /**
     * @dataProvider embedWithSetArgumentsProvider
     */
    public function testEmbedWithSetArguments($provider, $id, $embed)
    {
        $this->assertSame($embed, (new Ripple())->embed($provider, $id));
    }

    public function embedWithSetArgumentsProvider()
    {
        return [
            ['UnknownProvider', '1234567890', null],
            ['YouTube', 'AbCxYz012_', self::EMBED_YOUTUBE.'AbCxYz012_'],
            ['Vimeo', '1234567890', self::EMBED_VIMEO.'1234567890'],
            ['SoundCloud', '1234567890', self::EMBED_SOUNDCLOUD.'1234567890'],
            ['Bandcamp', '1234567890', self::EMBED_BANDCAMP.'1234567890/'],
        ];
    }

    /**
     * @dataProvider setEmbedParamsProvider
     */
    public function testSetEmbedParams($params, $provider, $id, $embed)
    {
        $ripple = new Ripple();
        $ripple->setEmbedParams($params);
{'fraction_non_alphanumeric': 0.152317880794702, 'fraction_numerical': 0.03016924208977189, 'mean_word_length': 2.855791962174941, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 18, 'lorem ipsum': 0, 'www.': 6, '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': '1163037', 'n_tokens_mistral': 2919, 'n_tokens_neox': 2652, 'n_words': 421}