Esempio n. 1
0
 public function testMerge()
 {
     $this->if($classController = new mock\controller())->and($classController->disableMethodChecking())->and($classController->__construct = function () {
     })->and($classController->getName = function () use(&$className) {
         return $className;
     })->and($classController->getFileName = function () use(&$classFile) {
         return $classFile;
     })->and($classController->getTraits = array())->and($classController->getStartLine = 1)->and($classController->getEndLine = 12)->and($class = new \mock\reflectionClass(uniqid(), $classController))->and($methodController = new mock\controller())->and($methodController->__construct = function () {
     })->and($methodController->getName = function () use(&$methodName) {
         return $methodName;
     })->and($methodController->isAbstract = false)->and($methodController->getFileName = function () use(&$classFile) {
         return $classFile;
     })->and($methodController->getDeclaringClass = function () use($class) {
         return $class;
     })->and($methodController->getStartLine = 6)->and($methodController->getEndLine = 8)->and($method = new \mock\reflectionMethod(uniqid(), uniqid(), $methodController))->and($classController->getMethod = function () use($method) {
         return $method;
     })->and($classController->getMethods = array($method))->and($classFile = uniqid())->and($className = uniqid())->and($methodName = uniqid())->and($xdebugData = array($classFile => array(5 => -2, 6 => -1, 7 => 1, 8 => -2, 9 => -2), uniqid() => array(5 => 2, 6 => 3, 7 => 4, 8 => 3, 9 => 2)))->and($coverage = new testedClass())->and($coverage->setReflectionClassFactory(function () use($class) {
         return $class;
     }))->then->object($coverage->merge($coverage))->isIdenticalTo($coverage)->array($coverage->getClasses())->isEmpty()->array($coverage->getMethods())->isEmpty()->if($otherCoverage = new testedClass())->then->object($coverage->merge($otherCoverage))->isIdenticalTo($coverage)->array($coverage->getClasses())->isEmpty()->array($coverage->getMethods())->isEmpty()->if($coverage->addXdebugDataForTest($this, $xdebugData))->then->object($coverage->merge($otherCoverage))->isIdenticalTo($coverage)->array($coverage->getClasses())->isEqualTo(array($className => $classFile))->array($coverage->getMethods())->isEqualTo(array($className => array($methodName => array(6 => -1, 7 => 1, 8 => -2))))->object($coverage->merge($coverage))->isIdenticalTo($coverage)->array($coverage->getClasses())->isEqualTo(array($className => $classFile))->array($coverage->getMethods())->isEqualTo(array($className => array($methodName => array(6 => -1, 7 => 1, 8 => -2))))->if($otherClassController = new mock\controller())->and($otherClassController->disableMethodChecking())->and($otherClassController->__construct = function () {
     })->and($otherClassController->getName = function () use(&$otherClassName) {
         return $otherClassName;
     })->and($otherClassController->getFileName = function () use(&$otherClassFile) {
         return $otherClassFile;
     })->and($otherClassController->getTraits = array())->and($otherClassController->getStartLine = 1)->and($otherClassController->getEndLine = 12)->and($otherClass = new \mock\reflectionClass($class, $otherClassController))->and($otherMethodController = new mock\controller())->and($otherMethodController->__construct = function () {
     })->and($otherMethodController->getName = function () use(&$otherMethodName) {
         return $otherMethodName;
     })->and($otherMethodController->isAbstract = false)->and($otherMethodController->getFileName = function () use(&$otherClassFile) {
         return $otherClassFile;
     })->and($otherMethodController->getDeclaringClass = function () use($otherClass) {
         return $otherClass;
     })->and($otherMethodController->getStartLine = 5)->and($otherMethodController->getEndLine = 9)->and($otherClassController->getMethods = array(new \mock\reflectionMethod(uniqid(), uniqid(), $otherMethodController)))->and($otherClassFile = uniqid())->and($otherClassName = uniqid())->and($otherMethodName = uniqid())->and($otherXdebugData = array($otherClassFile => array(1 => -2, 2 => -1, 3 => 1, 4 => 1, 5 => -1, 6 => 1, 7 => 1, 8 => -1, 9 => -2, 10 => 1), uniqid() => array(500 => 200, 600 => 300, 700 => 400, 800 => 300, 900 => 200)))->and($otherCoverage->setReflectionClassFactory(function () use($otherClass) {
         return $otherClass;
     }))->then->object($coverage->merge($otherCoverage->addXdebugDataForTest($this, $otherXdebugData)))->isIdenticalTo($coverage)->array($coverage->getClasses())->isEqualTo(array($className => $classFile, $otherClassName => $otherClassFile))->array($coverage->getMethods())->isEqualTo(array($className => array($methodName => array(6 => -1, 7 => 1, 8 => -2)), $otherClassName => array($otherMethodName => array(5 => -1, 6 => 1, 7 => 1, 8 => -1, 9 => -2))))->if($classController = new mock\controller())->and($classController->disableMethodChecking())->and($classController->__construct = function () {
     })->and($classController->getName = function () use(&$className) {
         return $className;
     })->and($classController->getFileName = function () use(&$classFile) {
         return $classFile;
     })->and($classController->getTraits = array())->and($classController->getStartLine = 1)->and($classController->getEndLine = 12)->and($class = new \mock\reflectionClass(uniqid(), $classController))->and($methodController = new mock\controller())->and($methodController->__construct = function () {
     })->and($methodController->getName = function () use(&$methodName) {
         return $methodName;
     })->and($methodController->isAbstract = false)->and($methodController->getFileName = function () use(&$classFile) {
         return $classFile;
     })->and($methodController->getDeclaringClass = function () use($class) {
         return $class;
     })->and($methodController->getStartLine = 6)->and($methodController->getEndLine = 8)->and($method = new \mock\reflectionMethod(uniqid(), uniqid(), $methodController))->and($classController->getMethod = function () use($method) {
         return $method;
     })->and($classController->getMethods = array($method))->and($classFile = uniqid())->and($className = uniqid())->and($methodName = uniqid())->and($xdebugData = array($classFile => array(5 => -2, 6 => -1, 7 => 1, 8 => -2, 9 => -2), uniqid() => array(5 => 2, 6 => 3, 7 => 4, 8 => 3, 9 => 2)))->and($coverage = new testedClass())->and($coverage->setReflectionClassFactory(function () use($class) {
         return $class;
     }))->and($coverage->excludeClass($className))->and($otherCoverage = new testedClass())->and($otherCoverage->setReflectionClassFactory(function () use($class) {
         return $class;
     }))->and($otherCoverage->addXdebugDataForTest($this, $xdebugData))->then->array($otherCoverage->getClasses())->isNotEmpty()->array($otherCoverage->getMethods())->isNotEmpty()->object($coverage->merge($otherCoverage))->isIdenticalTo($coverage)->array($coverage->getClasses())->isEmpty()->array($coverage->getMethods())->isEmpty();
 }