/** * Prepare the class array with the buildClasses */ private function setBuildClasses() { if ($this->isBuild === true) { return; } if (count($this->getClasses()) === 0) { throw new \Exception('No classes defined, please call setCLasses()'); } $this->buildClasses = []; foreach ($this->getOrdererClasses() as $class) { $build = new BuildClass(); $build->setClass($class); if ($build->canBeCached() === true) { $this->buildClasses[$class->getName()] = $build; } } $this->isBuild = true; }
/** * @covers SpeedLoader\BuildClass::canBeCached */ public function testCanBeCached() { /* * isInternal */ $classRef = $this->getClassReflection('SplHeap'); $classRef->expects($this->any())->method('isInternal')->willReturn(true); $buildClass = new BuildClass(); $buildClass->setClass($classRef); $this->assertFalse($buildClass->canBeCached()); /* * Doctrine */ $classRef = $this->getClassReflection('SplHeap'); $classRef->expects($this->any())->method('isInternal')->willReturn(false); $classRef->expects($this->any())->method('getName')->willReturn('Doctrine\\ORM\\MyClass'); $buildClass = new BuildClass(); $buildClass->setClass($classRef); $this->assertFalse($buildClass->canBeCached()); /* * Gedmo */ $classRef = $this->getClassReflection('SplHeap'); $classRef->expects($this->any())->method('isInternal')->willReturn(false); $classRef->expects($this->any())->method('getName')->willReturn('Gedmo\\ORM\\MyClass'); $buildClass = new BuildClass(); $buildClass->setClass($classRef); $this->assertFalse($buildClass->canBeCached()); /* * Pass */ $classRef = $this->getClassReflection('SplHeap'); $classRef->expects($this->any())->method('isInternal')->willReturn(false); $classRef->expects($this->any())->method('getName')->willReturn('Vendor\\MyClass'); $buildClass = new BuildClass(); $buildClass->setClass($classRef); $this->assertTrue($buildClass->canBeCached()); }