Completed
Pull Request — master (#912)
by
unknown
07:49
created

AutoloadRestorerTest::restoration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
/**
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Util;
9
10
/**
11
 * Class AutoloadRestorerTest
12
 *
13
 * @package N98\Util
14
 */
15
class AutoloadRestorerTest extends \PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * @test
19
     */
20
    public function creation()
21
    {
22
        $restorer = new AutoloadRestorer();
23
24
        $this->assertInstanceOf('N98\Util\AutoloadRestorer', $restorer);
25
    }
26
27
    /**
28
     * @test
29
     */
30
    public function restoration()
31
    {
32
        $callbackStub = function () {
33
        };
34
35
        $this->assertTrue(spl_autoload_register($callbackStub));
36
37
        $restorer = new AutoloadRestorer();
38
39
        $this->assertTrue(in_array($callbackStub, spl_autoload_functions(), true));
40
41
        $this->assertTrue(spl_autoload_unregister($callbackStub));
42
43
        $this->assertFalse(in_array($callbackStub, spl_autoload_functions(), true));
44
45
        $restorer->restore();
46
47
        $this->assertTrue(in_array($callbackStub, spl_autoload_functions(), true));
48
    }
49
}
50