| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Go! AOP framework | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @copyright Copyright 2015, Lisachenko Alexander <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * This source file is subject to the license that is bundled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * with this source code in the file LICENSE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace Go\Symfony\GoAopBundle\Tests\Kernel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Go\Instrument\ClassLoading\AopComposerLoader; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Go\Symfony\GoAopBundle\Kernel\AspectSymfonyKernel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Symfony\Component\Debug\DebugClassLoader; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * Class AspectSymfonyKernelTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | class AspectSymfonyKernelTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @runInSeparateProcess | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |     public function itInitializesAspectKernel() | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |         require_once __DIR__.'/../Fixtures/mock/DebugClassLoader.php'; | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         DebugClassLoader::reset(); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         DebugClassLoader::enable(); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |         $this->assertTrue(DebugClassLoader::$enabled); | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         AspectSymfonyKernel::getInstance()->init([ | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |             'appDir' => __DIR__, | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |             'cacheDir' => sys_get_temp_dir() | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         ]); | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |         $this->assertTrue(DebugClassLoader::$enabled); | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         $this->assertEquals(['enable', 'disable', 'enable'], DebugClassLoader::$invocations); | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @runInSeparateProcess | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @expectedException \RuntimeException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @expectedExceptionMessage Initialization of AOP loader was failed, probably due to Debug::enable() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     public function itThrowsExceptionWhenIntializationIsImpossible() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         require_once __DIR__.'/../Fixtures/mock/DebugClassLoader.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         require_once __DIR__.'/../Fixtures/mock/AopComposerLoader.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         AopComposerLoader::$initialized = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         AspectSymfonyKernel::getInstance()->init([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             'appDir' => __DIR__, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             'cacheDir' => sys_get_temp_dir() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 62 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |  |