<commit_before><?php
/**
 * @package    Fuel\Dependency
 * @version    2.0
 * @author     Fuel Development Team
 * @license    MIT License
 * @copyright  2010 - 2014 Fuel Development Team
 * @link       http://fuelphp.com
 */

namespace Fuel\Dependency;

use Codeception\TestCase\Test;

class ContainerTest extends Test
{
	/**
	 * @expectedException \Fuel\Dependency\ResolveException
	 */
	public function testResolveFail()
	{
		$container = new Container();
		$container->resolve('unknown.dependency');
	}

	/**
	 * @expectedException \Fuel\Dependency\ResolveException
	 */
	public function testForgeFail()
	{
		$container = new Container();
		$container->forge('unknown.dependency');
	}

	/**
	 * @expectedException \Fuel\Dependency\ResolveException
	 */
	public function testAbstractFail()
	{
		$container = new Container();
		$container->forge('AbstractClass');
	}

	/**
	 * @expectedException \Fuel\Dependency\ResolveException
	 */
	public function testMultitonFail()
	{
		$container = new Container();
		$container->multiton('unknown.dependency');
		$container->isInstance('unknown','dependency');
	}

	public function testForgingProvider()
	{
		$container = new Container();
		$container->registerService(new \ForgingProvider());
		$this->assertInstanceOf('stdClass', $container['forging.name']);
		$this->assertInstanceOf('stdClass', $container->forge('forging.name', array(true)));
	}

	public function testRegisteringService()
	{
		$container = new Container();
		$container->registerService(new \RegisteringService());
		$this->assertInstanceOf('stdClass', $container['from.service']);
		$this->assertEquals('This Works!', $container['from.service']->forge->extension);
	}

	public function testExtensionService()
	{
		$container = new Container();
		$container->registerService(new \ExtensionService());
		$container->register('id', 'stdClass');
		$container->extend('id', 'extension');
		$instance = $container['id'];
		$this->assertEquals('This Works!', $instance->extension);
	}

	public function testInjectingService()
	{
		$container = new Container();
		$container->registerServices(array(new \InjectingService()));
		$this->assertInstanceOf('Fuel\Dependency\ServiceProvider', $container['service']);
	}

	public function testSingletons()
	{
		$container = new Container;
		$container->registerSingleton('single', 'stdClass');
		$container->register('other', 'stdClass');
		$this->assertTrue($container['single'] === $container['single']);
		$this->assertTrue($container['single'] !== $container['other']);
		$this->assertTrue($container['single'] !== $container->forge('single'));
		$this->assertTrue($container['single'] == $container['other']);
		$this->assertTrue($container->isInstance('single'));<commit_msg>Hello php 5.4 array<commit_after><?php
/**
 * @package    Fuel\Dependency
 * @version    2.0
 * @author     Fuel Development Team
 * @license    MIT License
 * @copyright  2010 - 2014 Fuel Development Team
 * @link       http://fuelphp.com
 */

namespace Fuel\Dependency;

use Codeception\TestCase\Test;

class ContainerTest extends Test
{
	/**
	 * @expectedException \Fuel\Dependency\ResolveException
	 */
	public function testResolveFail()
	{
		$container = new Container();
		$container->resolve('unknown.dependency');
	}

	/**
	 * @expectedException \Fuel\Dependency\ResolveException
	 */
	public function testForgeFail()
	{
		$container = new Container();
		$container->forge('unknown.dependency');
	}

	/**
	 * @expectedException \Fuel\Dependency\ResolveException
	 */
	public function testAbstractFail()
	{
		$container = new Container();
		$container->forge('AbstractClass');
	}

	/**
	 * @expectedException \Fuel\Dependency\ResolveException
	 */
	public function testMultitonFail()
	{
		$container = new Container();
		$container->multiton('unknown.dependency');
		$container->isInstance('unknown','dependency');
	}

	public function testForgingProvider()
	{
		$container = new Container();
		$container->registerService(new \ForgingProvider());
		$this->assertInstanceOf('stdClass', $container['forging.name']);
		$this->assertInstanceOf('stdClass', $container->forge('forging.name',  [true]));
	}

	public function testRegisteringService()
	{
		$container = new Container();
		$container->registerService(new \RegisteringService());
		$this->assertInstanceOf('stdClass', $container['from.service']);
		$this->assertEquals('This Works!', $container['from.service']->forge->extension);
	}

	public function testExtensionService()
	{
		$container = new Container();
		$container->registerService(new \ExtensionService());
		$container->register('id', 'stdClass');
		$container->extend('id', 'extension');
		$instance = $container['id'];
		$this->assertEquals('This Works!', $instance->extension);
	}

	public function testInjectingService()
	{
		$container = new Container();
		$container->registerServices([new \InjectingService()]);
		$this->assertInstanceOf('Fuel\Dependency\ServiceProvider', $container['service']);
	}

	public function testSingletons()
	{
		$container = new Container;
		$container->registerSingleton('single', 'stdClass');
		$container->register('other', 'stdClass');
		$this->assertTrue($container['single'] === $container['single']);
		$this->assertTrue($container['single'] !== $container['other']);
		$this->assertTrue($container['single'] !== $container->forge('single'));
		$this->assertTrue($container['single'] == $container['other']);
		$this->assertTrue($container->isInstance('single'));
{'fraction_non_alphanumeric': 0.17524262955502656, 'fraction_numerical': 0.004028566196667277, 'mean_word_length': 5.533492822966507, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3717873', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1534, 'n_words': 276}