<commit_before><?php

namespace PhraseanetSDK\Tests;

use PhraseanetSDK\PhraseanetSDKServiceProvider;
use Silex\Application;
use Silex\Provider\WebProfilerServiceProvider;
use Silex\Provider\TwigServiceProvider;
use PhraseanetSDK\Cache\CanCacheStrategy;
use PhraseanetSDK\Cache\RevalidationFactory;
use PhraseanetSDK\Cache\CacheFactory;
use PhraseanetSDK\Exception\ExceptionInterface;

class PhraseanetSDKServiceProviderTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider provideServices
     */
    public function testServices($name, $instanceOf)
    {
        $app = $this->getConfiguredApplication();
        $app->register(new PhraseanetSDKServiceProvider(), array(
            'phraseanet-sdk.config' => array(
                'client-id' => 'sdfmqlsdkfm',
                'secret'    => 'eoieep',
                'url'       => 'https://bidule.net',
            )
        ));
        $app->boot();

        $this->assertInstanceOf($instanceOf, $app[$name]);
    }

    public function provideServices()
    {
        return array(
            array('phraseanet-sdk', 'PhraseanetSDK\Application'),
            array('phraseanet-sdk.cache.factory', 'PhraseanetSDK\Cache\CacheFactory'),
            array('phraseanet-sdk.guzzle.revalidation-factory', 'PhraseanetSDK\Cache\RevalidationFactory'),
            array('phraseanet-sdk.guzzle.can-cache-strategy', 'PhraseanetSDK\Cache\CanCacheStrategy'),
            array('phraseanet-sdk.recorder', 'PhraseanetSDK\Recorder\Recorder'),
            array('phraseanet-sdk.player', 'PhraseanetSDK\Recorder\Player'),
        );
    }

    /**
     * @dataProvider provideServicesWithProfiler
     */
    public function testServicesWithProfiler($name, $instanceOf)
    {
        $app = $this->getConfiguredApplication();
        $app->register(new TwigServiceProvider());
        $app->register(new WebProfilerServiceProvider(), array(
            'profiler.cache_dir' => __DIR__ . '/cache',
        ));<commit_msg>Add player factory unit test<commit_after><?php

namespace PhraseanetSDK\Tests;

use PhraseanetSDK\PhraseanetSDKServiceProvider;
use Silex\Application;
use Silex\Provider\WebProfilerServiceProvider;
use Silex\Provider\TwigServiceProvider;
use PhraseanetSDK\Cache\CanCacheStrategy;
use PhraseanetSDK\Cache\RevalidationFactory;
use PhraseanetSDK\Cache\CacheFactory;
use PhraseanetSDK\Exception\ExceptionInterface;

class PhraseanetSDKServiceProviderTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider provideServices
     */
    public function testServices($name, $instanceOf)
    {
        $app = $this->getConfiguredApplication();
        $app->register(new PhraseanetSDKServiceProvider(), array(
            'phraseanet-sdk.config' => array(
                'client-id' => 'sdfmqlsdkfm',
                'secret'    => 'eoieep',
                'url'       => 'https://bidule.net',
            )
        ));
        $app->boot();

        $this->assertInstanceOf($instanceOf, $app[$name]);
    }

    public function provideServices()
    {
        return array(
            array('phraseanet-sdk', 'PhraseanetSDK\Application'),
            array('phraseanet-sdk.cache.factory', 'PhraseanetSDK\Cache\CacheFactory'),
            array('phraseanet-sdk.guzzle.revalidation-factory', 'PhraseanetSDK\Cache\RevalidationFactory'),
            array('phraseanet-sdk.guzzle.can-cache-strategy', 'PhraseanetSDK\Cache\CanCacheStrategy'),
            array('phraseanet-sdk.recorder', 'PhraseanetSDK\Recorder\Recorder'),
        );
    }

    public function testPlayerFactory()
    {
        $app = $this->getConfiguredApplication();
        $app->register(new PhraseanetSDKServiceProvider(), array(
            'phraseanet-sdk.config' => array(
                'client-id' => 'sdfmqlsdkfm',
                'secret'    => 'eoieep',
                'url'       => 'https://bidule.net',
            )
        ));
        $app->boot();

        $player1 = $app['phraseanet-sdk.player.factory']('token');
        $player2 = $app['phraseanet-sdk.player.factory']('token');
        $this->assertInstanceOf('PhraseanetSDK\Recorder\Player', $player1);
        $this->assertInstanceOf('PhraseanetSDK\Recorder\Player', $player2);
        $this->assertNotSame($player2, $player1);
    }

    /**
     * @dataProvider provideServicesWithProfiler
     */
    public function testServicesWithProfiler($name, $instanceOf)
    {
        $app = $this->getConfiguredApplication();
        $app->register(new TwigServiceProvider());
        $app->register(new WebProfilerServiceProvider(), array(
            'profiler.cache_dir' => __DIR__ . '/cache',
        ));
{'fraction_non_alphanumeric': 0.1320673284419508, 'fraction_numerical': 0.001294777729823047, 'mean_word_length': 2.9213197969543145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 3, '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': '4669032', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1381, 'n_words': 185}