<?php

namespace Spark\Test\Util;

use PHPUnit_Framework_TestCase,
    Spark\Util;

class ClassLoaderTest extends PHPUnit_Framework_TestCase
{
    function setUp()
    {
        $this->classLoader = Util\ClassLoader();
    }
    
    function testClassLoaderActsAsSingleton()
    {
        $instance1 = Util\ClassLoader();
        $instance2 = Util\ClassLoader();
        $this->assertEquals($instance1, $instance2);
    }
    
    function testClassLoaderRegistersOnSplAutoloadStack()
    {
        $classLoader = $this->classLoader;
        $this->assertTrue(in_array($classLoader, spl_autoload_functions(), true));
    }
    
    function testClassLoaderCanBeUnregisteredFromSplAutoloadStack()
    {
        $classLoader = $this->classLoader;
        $classLoader->unregister();
        $this->assertFalse(in_array($classLoader, spl_autoload_functions(), true));
        
        $classLoader->register();
    }
    
    function testAutoloadFunction()
    {
        autoload("Spark\Test\SampleClass", TESTS . "/Spark/_data/SampleClass.php");
        $this->assertTrue(class_exists("Spark\Test\SampleClass"), "Sample Class is not loadable");
    }
}

<?php

namespace Spark\Test\Util;

use PHPUnit_Framework_TestCase,
    Spark\Util;

class ClassLoaderTest extends PHPUnit_Framework_TestCase
{
    function setUp()
    {
        $this->classLoader = Util\ClassLoader();
    }
    
    function testClassLoaderActsAsSingleton()
    {
        $instance1 = Util\ClassLoader();
        $instance2 = Util\ClassLoader();
        $this->assertSame($instance1, $instance2);
    }
    
    function testClassLoaderRegistersOnSplAutoloadStack()
    {
        $classLoader = $this->classLoader;
        $this->assertTrue(in_array($classLoader, spl_autoload_functions(), true));
    }
    
    function testClassLoaderCanBeUnregisteredFromSplAutoloadStack()
    {
        $classLoader = $this->classLoader;
        $classLoader->unregister();
        $this->assertFalse(in_array($classLoader, spl_autoload_functions(), true));
        
        $classLoader->register();
    }
    
    function testAutoloadFunction()
    {
        autoload("Spark\Test\SampleClass", TESTS . "/Spark/_data/SampleClass.php");
        $this->assertTrue(class_exists("Spark\Test\SampleClass"), "Sample Class is not loadable");
    }
}

Use PHPUnit_Framework_Assert::assertSame() to check if the variables refer to the same ClassLoader instances
Use PHPUnit_Framework_Assert::assertSame() to check if the variables refer to the same ClassLoader instances
