@@ 69-84 (lines=16) @@ | ||
66 | /** |
|
67 | * Tests that class files are loaded correctly. |
|
68 | */ |
|
69 | public function test_load_class() { |
|
70 | $loader = $this->getMockBuilder( Version_Loader::class ) |
|
71 | ->disableOriginalConstructor() |
|
72 | ->setMethods( array( 'find_class_file' ) ) |
|
73 | ->getMock(); |
|
74 | ||
75 | global $jetpack_autoloader_loader; |
|
76 | $jetpack_autoloader_loader = $loader; |
|
77 | $loader->expects( $this->once() ) |
|
78 | ->method( 'find_class_file' ) |
|
79 | ->with( Test::class ) |
|
80 | ->willReturn( TEST_DATA_PATH . '/plugins/dummy_current/includes/class-test.php' ); |
|
81 | ||
82 | $this->assertTrue( PHP_Autoloader::load_class( Test::class ) ); |
|
83 | $this->assertTrue( class_exists( Test::class, false ) ); |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * Tests that nothing happens when a class file isn't found. |
|
@@ 89-104 (lines=16) @@ | ||
86 | /** |
|
87 | * Tests that nothing happens when a class file isn't found. |
|
88 | */ |
|
89 | public function test_load_class_does_nothing_without_class() { |
|
90 | $loader = $this->getMockBuilder( Version_Loader::class ) |
|
91 | ->disableOriginalConstructor() |
|
92 | ->setMethods( array( 'find_class_file' ) ) |
|
93 | ->getMock(); |
|
94 | ||
95 | global $jetpack_autoloader_loader; |
|
96 | $jetpack_autoloader_loader = $loader; |
|
97 | $loader->expects( $this->once() ) |
|
98 | ->method( 'find_class_file' ) |
|
99 | ->with( Test::class ) |
|
100 | ->willReturn( null ); |
|
101 | ||
102 | $this->assertFalse( PHP_Autoloader::load_class( Test::class ) ); |
|
103 | $this->assertFalse( class_exists( Test::class, false ) ); |
|
104 | } |
|
105 | } |
|
106 |