public function execute(array $files) { $coupling = new Coupling(); $couplingMap = $coupling->calculate($this->classMap); // link between coupling and files $fileCoupling = new FileCoupling($this->classMap, $couplingMap); foreach ($files as $filename) { $rCoupling = $fileCoupling->calculate($filename); $this->collection->get($filename)->setCoupling($rCoupling); } }
public function testCouplingTakesCareOfReturnedValues() { $filename = __DIR__ . '/../../../../../resources/coupling/f1.php'; $extractor = new Extractor(new Tokenizer()); $classmap = new ClassMap(); $classmap->push($filename, $extractor->extract($filename)); $coupling = new Coupling(); $this->result = $coupling->calculate($classmap); $this->assertEquals(0, $this->result->get('\\ClassWhoUseAnother')->getAfferentCoupling()); $this->assertEquals(1, $this->result->get('\\ClassWhoUseAnother')->getEfferentCoupling()); $this->assertEquals(1, $this->result->get('\\ClassWhoIsUsed')->getAfferentCoupling()); $this->assertEquals(0, $this->result->get('\\ClassWhoIsUsed')->getEfferentCoupling()); }
public function setup() { $classesInfos = array('\\Ns1\\Class1' => array('\\Ns1\\Class2', '\\Ns2\\Class1'), '\\Ns1\\Class2' => array('\\Ns2\\Class1'), '\\Ns2\\Class1' => array()); $classes = array(); foreach ($classesInfos as $classname => $dependencies) { $class = $this->getMockBuilder('\\Hal\\Component\\OOP\\Reflected\\ReflectedClass')->disableOriginalConstructor()->getMock(); $class->expects($this->any())->method('getFullname')->will($this->returnValue($classname)); $class->expects($this->once())->method('getDependencies')->will($this->returnValue($dependencies)); array_push($classes, $class); } $result = $this->getMock('\\Hal\\Component\\OOP\\Extractor\\Result'); $result->expects($this->any())->method('getClasses')->will($this->returnValue($classes)); $results = array($result); $classMap = $this->getMockBuilder('\\Hal\\Component\\OOP\\Extractor\\ClassMap')->disableOriginalConstructor()->getMock(); $classMap->expects($this->once())->method('all')->will($this->returnValue($results)); $coupling = new Coupling(); $this->result = $coupling->calculate($classMap); }