<commit_before><?php

namespace HumusSupervisorModuleTest;

use HumusSupervisorModule\SupervisorAbstractServiceFactory;
use PHPUnit_Framework_TestCase as TestCase;
use Zend\ServiceManager\ServiceManager;

class SupervisorAbstractServiceFactoryTest extends TestCase
{
    /**
     * @var ServiceManager
     */
    protected $services;

    /**
     * @var SupervisorAbstractServiceFactory
     */
    protected $components;

    public function setUp()
    {
        $services    = $this->services = new ServiceManager();
        $services->setAllowOverride(true);

        $services->setService('Config', array(
            'humus_supervisor_module' => array(
                'test-supervisor' => array(
                    'host' => 'localhost',
                    'username' => 'user',
                    'password' => '<PASSWORD>'
                )
            )
        ));

        $compontents = $this->components = new SupervisorAbstractServiceFactory();
        $services->addAbstractFactory($compontents);
    }

    public function testMissingConfigServiceIndicatesCannotCreateInstance()
    {
        $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
    }

    public function testMissingSupervisorServicePrefixIndicatesCannotCreateInstance()
    {
        $this->services->setService('Config', array());
        $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
    }

    public function testMissingConfigIndicatesCannotCreateInstance()
    {
        $this->services->setService('Config', null);
        $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
    }

    public function testInvalidConfigIndicatesCannotCreateInstance()
    {
        $this->services->setService('Config', array('humus_amqp_module' => 'string'));
        $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
    }

    public function testEmptySupervisorConfigIndicatesCannotCreateConsumer()
    {
        $this->services->setService('Config', array('humus_amqp_module' => array()));
        $this->assertFalse(
            $this->components->canCreateServiceWithName($this->services, 'test-consumer', 'test-consumer')
        );
    }

    public function testSupervisorFactory()
    {
        $this->assertTrue(
            $this->components->canCreateServiceWithName(
                $this->services,
                'test-supervisor',
                'test-supervisor'
            )
        );

        $supervisor = $this->components->createServiceWithName(
            $this->services,
            'test-supervisor',
            'test-supervisor'
        );
        $this->assertInstanceOf('Indigo\Supervisor\Supervisor', $supervisor);

        $this->assertTrue(
            $this->components->canCreateServiceWithName(
                $this->services,
                'test-supervisor',
                'test-supervisor'
            )
        );

        $supervisor2 = $this->components->createServiceWithName(
            $this->services,
            'test-supervisor',
            'test-supervisor'
        );

        $this->assertSame($supervisor, $supervisor2);
    }

    public function testMissingSpecIndicatesCannotCreateSupervisor()
    {
        $this->services->setService('Config', array(
            'humus_supervisor_module' => array(
                'test-supervisor' => array(
                ),
            ),
        ));
        $this->assertFalse(
            $this->components->canCreateServiceWithName(
                $this->services,
                'test-supervisor',
                'test-supervisor'
            )
        );
    }

}
<commit_msg>php cs fixes in SupervisorAbstractServiceFactoryTest<commit_after><?php

namespace HumusSupervisorModuleTest;

use HumusSupervisorModule\SupervisorAbstractServiceFactory;
use PHPUnit_Framework_TestCase as TestCase;
use Zend\ServiceManager\ServiceManager;

class SupervisorAbstractServiceFactoryTest extends TestCase
{
    /**
     * @var ServiceManager
     */
    protected $services;

    /**
     * @var SupervisorAbstractServiceFactory
     */
    protected $components;

    public function setUp()
    {
        $services    = $this->services = new ServiceManager();
        $services->setAllowOverride(true);

        $services->setService('Config', array(
            'humus_supervisor_module' => array(
                'test-supervisor' => array(
                    'host' => 'localhost',
                    'username' => 'user',
                    'password' => '<PASSWORD>'
                )
            )
        ));

        $compontents = $this->components = new SupervisorAbstractServiceFactory();
        $services->addAbstractFactory($compontents);
    }

    public function testMissingConfigServiceIndicatesCannotCreateInstance()
    {
        $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
    }

    public function testMissingSupervisorServicePrefixIndicatesCannotCreateInstance()
    {
        $this->services->setService('Config', array());
        $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
    }

    public function testMissingConfigIndicatesCannotCreateInstance()
    {
        $this->services->setService('Config', null);
        $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
    }

    public function testInvalidConfigIndicatesCannotCreateInstance()
    {
        $this->services->setService('Config', array('humus_amqp_module' => 'string'));
        $this->assertFalse($this->components->canCreateServiceWithName($this->services, 'foo', 'foo'));
    }

    public function testEmptySupervisorConfigIndicatesCannotCreateConsumer()
    {
        $this->services->setService('Config', array('humus_amqp_module' => array()));
        $this->assertFalse(
            $this->components->canCreateServiceWithName($this->services, 'test-consumer', 'test-consumer')
        );
    }

    public function testSupervisorFactory()
    {
        $this->assertTrue(
            $this->components->canCreateServiceWithName(
                $this->services,
                'test-supervisor',
                'test-supervisor'
            )
        );

        $supervisor = $this->components->createServiceWithName(
            $this->services,
            'test-supervisor',
            'test-supervisor'
        );
        $this->assertInstanceOf('Indigo\Supervisor\Supervisor', $supervisor);

        $this->assertTrue(
            $this->components->canCreateServiceWithName(
                $this->services,
                'test-supervisor',
                'test-supervisor'
            )
        );

        $supervisor2 = $this->components->createServiceWithName(
            $this->services,
            'test-supervisor',
            'test-supervisor'
        );

        $this->assertSame($supervisor, $supervisor2);
    }

    public function testMissingSpecIndicatesCannotCreateSupervisor()
    {
        $this->services->setService('Config', array(
            'humus_supervisor_module' => array(
                'test-supervisor' => array(
                ),
            ),
        ));
        $this->assertFalse(
            $this->components->canCreateServiceWithName(
                $this->services,
                'test-supervisor',
                'test-supervisor'
            )
        );
    }
}

{'fraction_non_alphanumeric': 0.1266225165562914, 'fraction_numerical': 0.0005298013245033113, 'mean_word_length': 2.341150442477876, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 133, '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': '680838', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1902, 'n_words': 264}