<commit_before><?php
/**
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */

/**
 * @namespace
 */
namespace Bluz\Tests\Common;

use Bluz\Tests\TestCase;
use Bluz\Tests\Common\Fixtures\ConcreteSingleton;

/**
 * SingletonTest
 *
 * @package  Bluz\Tests\Common
 *
 * @author   <NAME>
 * @created  12.08.2014 13:24
 */
class SingletonTest extends TestCase
{
    /**
     * Test GetInstance
     */
    public function testGetInstance()
    {
        $result = ConcreteSingleton::getInstance();
        $result->foo = 'bar';

        self::assertInstanceOf('Bluz\Tests\Common\Fixtures\ConcreteSingleton', $result);
        self::assertEquals(ConcreteSingleton::getInstance(), $result);
        self::assertEquals('bar', ConcreteSingleton::getInstance()->foo);
    }

    /**
     * Test Clone
     */
    public function testPrivateMethods()
    {
        $result = ConcreteSingleton::getInstance();

        $reflection = new \ReflectionObject($result);

        self::assertTrue($reflection->getMethod('__construct')->isPrivate());
        self::assertTrue($reflection->getMethod('__clone')->isPrivate());
        self::assertTrue($reflection->getMethod('__wakeup')->isPrivate());
    }
}<commit_msg>Added tests for Singleton trait<commit_after><?php
/**
 * @copyright Bluz PHP Team
 * @link https://github.com/bluzphp/framework
 */

/**
 * @namespace
 */
namespace Bluz\Tests\Common;

use Bluz\Tests\TestCase;
use Bluz\Tests\Common\Fixtures\ConcreteSingleton;

/**
 * SingletonTest
 *
 * @package  Bluz\Tests\Common
 *
 * @author   <NAME>
 * @created  12.08.2014 13:24
 */
class SingletonTest extends TestCase
{
    /**
     * Test GetInstance
     */
    public function testGetInstance()
    {
        $result = ConcreteSingleton::getInstance();
        $result->foo = 'bar';

        self::assertInstanceOf('Bluz\Tests\Common\Fixtures\ConcreteSingleton', $result);
        self::assertEquals(ConcreteSingleton::getInstance(), $result);
        self::assertEquals('bar', ConcreteSingleton::getInstance()->foo);
    }

    /**
     * Test Clone
     */
    public function testPrivateMethods()
    {
        $result = ConcreteSingleton::getInstance();

        $reflection = new \ReflectionObject($result);

        self::assertTrue($reflection->getMethod('__construct')->isPrivate());
        self::assertTrue($reflection->getMethod('__clone')->isPrivate());
        self::assertTrue($reflection->getMethod('__wakeup')->isPrivate());
    }

    /**
     * Test Construct Throw Error
     *
     * @expectedException \Error
     */
    public function testConstructThrowError()
    {
        new ConcreteSingleton();
    }

    /**
     * Test Clone Throw Error
     *
     * @expectedException \Error
     */
    public function testCloneThrowError()
    {
        $result = clone ConcreteSingleton::getInstance();
    }
}
{'fraction_non_alphanumeric': 0.1501227639424763, 'fraction_numerical': 0.008418098912662224, 'mean_word_length': 3.091822094691535, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '7131037', 'n_tokens_mistral': 836, 'n_tokens_neox': 819, 'n_words': 135}