public function testProxyLoadsTheInitialBaseClass() { //arrange $line1 = new CoveredLine('namespace SomeNamespace;'); $line2 = new CoveredLine('class ClassA{'); $line2->setClass(true); $line2->setClassName('ClassA'); $line3 = new CoveredLine('function returnSomething(){'); $line3->setMethod(true); $line3->setMethodName('returnSomething'); $line4 = new CoveredLine(' return "something"; }'); $line5 = new CoveredLine('}'); $exampleClass = new DynamicClassnameCoveredClass(); // implementation of ClassMetadata $exampleClass->setName('ClassA'); $exampleClass->setNamespace('SomeNamespace'); $exampleClass->addLine(1, $line1); $exampleClass->addLine(2, $line2); $exampleClass->addLine(3, $line3); $exampleClass->addLine(4, $line4); $exampleClass->addLine(5, $line5); //act $proxy = new ProxyAccessor($exampleClass); $proxy->load(); $instance = new \SomeNamespace\ClassA(); }
public function detectMethod($input, CoveredLine $line) { $match = preg_match(self::METHOD_PATTERN, $input, $matches); if (!$match) { return; } $line->setMethod(true); $line->setFinal($matches[1] === "final"); $line->setMethodName($matches[4]); }
public function testGetMethodSkippsConstructor() { $line1 = new CoveredLine("line1"); $line1->setMethod(true); $line1->setMethodName("method1"); $line2 = new CoveredLine("line2"); $line2->setMethod(true); $line2->setMethodName("__construct"); $class = new CoveredClass(); $class->addLine(1, $line1); $class->addLine(2, $line2); $this->assertEquals(array('method1'), $class->getMethods()); }
public function testMethodKnowsIfItsAConstructor() { $line = new CoveredLine(""); $line->setMethod(true); $line->setMethodName('__construct'); $this->assertTrue($line->isConstructor()); }