当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Util_Class类代码示例

本文整理汇总了PHP中PHPUnit_Util_Class的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Class类的具体用法?PHP PHPUnit_Util_Class怎么用?PHP PHPUnit_Util_Class使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PHPUnit_Util_Class类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testManufactureHandlers

 /**
  * @dataProvider handlerProvider
  */
 public function testManufactureHandlers($types, $options)
 {
     $handler = HandlerFactory::createHandler($types, $options);
     if (count($types) > 1) {
         $handlerclass = $this->handlers['Composite'];
         $h = \PHPUnit_Util_Class::getObjectAttribute($handler, 'drivers');
         $handlers = array_combine($types, $h);
     } else {
         $handlerclass = $this->handlers[$types[0]];
         $handlers = array($types[0] => $handler);
     }
     $this->assertInstanceOf($handlerclass, $handler);
     foreach ($handlers as $subtype => $subhandler) {
         $subhandlerclass = $this->handlers[$subtype];
         $this->assertInstanceOf($subhandlerclass, $subhandler);
     }
     foreach ($types as $type) {
         $defaults = isset($this->defaultSettings[$type]) ? $this->defaultSettings[$type] : array();
         $options = array_merge($defaults, $options);
         /*            foreach($options as $optname => $optvalue) {
                         $this->assertAttributeEquals($optvalue, $optname, $handlers[$type]);
                     }
         */
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:28,代码来源:HandlerFactoryTest.php

示例2: testGetObjectAttributeCanHandleDynamicVariables

 /**
  * Test that if a dynamic variable is defined on a class then
  * the $attribute variable will be NULL, but the variable defined
  * will be a public one so we are safe to return it
  *
  * Currently $attribute is NULL but we try and call isPublic() on it.
  * This breaks for php 5.2.10
  *
  * @covers PHPUnit_Util_Class::getObjectAttribute
  *
  * @return void
  */
 public function testGetObjectAttributeCanHandleDynamicVariables()
 {
     $attributeName = '_variable';
     $object = new stdClass();
     $object->{$attributeName} = 'Test';
     $actual = PHPUnit_Util_Class::getObjectAttribute($object, $attributeName);
     $this->assertEquals('Test', $actual);
 }
开发者ID:DieguinhoHR,项目名称:kratos_store,代码行数:20,代码来源:ClassTest.php

示例3: testSetThreshold

 /**
  * Test setThreshold method
  */
 public function testSetThreshold()
 {
     $thresholdKey = \Magento\Framework\Profiler\Driver\Standard\Stat::TIME;
     $this->_output->setThreshold($thresholdKey, 100);
     $thresholds = class_exists('PHPUnit_Util_Class') ? \PHPUnit_Util_Class::getObjectAttribute($this->_output, '_thresholds') : \PHPUnit_Framework_Assert::readAttribute($this->_output, '_thresholds');
     $this->assertArrayHasKey($thresholdKey, $thresholds);
     $this->assertEquals(100, $thresholds[$thresholdKey]);
     $this->_output->setThreshold($thresholdKey, null);
     $this->assertArrayNotHasKey($thresholdKey, $this->_output->getThresholds());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:OutputAbstractTest.php

示例4: load

 /**
  * @param  string  $suiteClassName
  * @param  string  $suiteClassFile
  * @return ReflectionClass
  * @throws RuntimeException
  */
 public function load($suiteClassName, $suiteClassFile = '')
 {
     $suiteClassName = str_replace('.php', '', $suiteClassName);
     if (empty($suiteClassFile)) {
         $suiteClassFile = PHPUnit_Util_Filesystem::classNameToFilename($suiteClassName);
     }
     if (!class_exists($suiteClassName, FALSE)) {
         PHPUnit_Util_Class::collectStart();
         $filename = PHPUnit_Util_Fileloader::checkAndLoad($suiteClassFile);
         $loadedClasses = PHPUnit_Util_Class::collectEnd();
     }
     if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) {
         $offset = 0 - strlen($suiteClassName);
         foreach ($loadedClasses as $loadedClass) {
             $class = new ReflectionClass($loadedClass);
             if (substr($loadedClass, $offset) === $suiteClassName && $class->getFileName() == $filename) {
                 $suiteClassName = $loadedClass;
                 break;
             }
         }
     }
     if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) {
         $testCaseClass = 'PHPUnit_Framework_TestCase';
         foreach ($loadedClasses as $loadedClass) {
             $class = new ReflectionClass($loadedClass);
             $classFile = $class->getFileName();
             if ($class->isSubclassOf($testCaseClass) && !$class->isAbstract()) {
                 $suiteClassName = $loadedClass;
                 $testCaseClass = $loadedClass;
                 if ($classFile == realpath($suiteClassFile)) {
                     break;
                 }
             }
             if ($class->hasMethod('suite')) {
                 $method = $class->getMethod('suite');
                 if (!$method->isAbstract() && $method->isPublic() && $method->isStatic()) {
                     $suiteClassName = $loadedClass;
                     if ($classFile == realpath($suiteClassFile)) {
                         break;
                     }
                 }
             }
         }
     }
     if (class_exists($suiteClassName, FALSE)) {
         $class = new ReflectionClass($suiteClassName);
         $filePath = $GLOBALS['base_dir'] . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . $suiteClassFile;
         if ($class->getFileName() == realpath($filePath)) {
             return $class;
         }
     }
     throw new PHPUnit_Framework_Exception(sprintf('Class %s could not be found in %s.', $suiteClassName, $suiteClassFile));
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:59,代码来源:StandardTestSuiteLoader.php

示例5: dirname

#!/usr/bin/env php
<?php 
require dirname(__DIR__) . '/PHPUnit/Autoload.php';
$buffer = '';
$class = new ReflectionClass('PHPUnit_Framework_Assert');
$methods = array();
foreach ($class->getMethods() as $method) {
    $docblock = $method->getDocComment();
    $name = $method->getName();
    if (strpos($name, 'assert') === 0 || strpos($docblock, '@return PHPUnit_Framework_Constraint') !== FALSE) {
        $methods[$name] = array('class' => 'PHPUnit_Framework_Assert', 'docblock' => $docblock, 'sigDecl' => str_replace(array('= false', '= true'), array('= FALSE', '= TRUE'), PHPUnit_Util_Class::getMethodParameters($method)), 'sigCall' => PHPUnit_Util_Class::getMethodParameters($method, TRUE));
    }
}
$class = new ReflectionClass('PHPUnit_Framework_TestCase');
foreach ($class->getMethods() as $method) {
    $docblock = $method->getDocComment();
    $name = $method->getName();
    if (strpos($docblock, '@return PHPUnit_Framework_MockObject_Matcher') !== FALSE || strpos($docblock, '@return PHPUnit_Framework_MockObject_Stub') !== FALSE) {
        $methods[$name] = array('class' => 'PHPUnit_Framework_TestCase', 'docblock' => $docblock, 'sigDecl' => str_replace(array('= false', '= true'), array('= FALSE', '= TRUE'), PHPUnit_Util_Class::getMethodParameters($method)), 'sigCall' => PHPUnit_Util_Class::getMethodParameters($method, TRUE));
    }
}
ksort($methods);
foreach ($methods as $name => $data) {
    $buffer .= sprintf("\n\n%s\nfunction %s(%s)\n{\n    return call_user_func_array(\n      '%s::%s',\n      func_get_args()\n    );\n}", str_replace('    ', '', $data['docblock']), $name, $data['sigDecl'], $data['class'], $name, $data['sigCall']);
}
$template = new Text_Template(dirname(__DIR__) . '/PHPUnit/Framework/Assert/Functions.php.in');
$template->setVar(array('functions' => $buffer));
$template->renderTo(dirname(__DIR__) . '/PHPUnit/Framework/Assert/Functions.php');
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:28,代码来源:assertions.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param  string                              $scope
  * @param  ReflectionFunction|ReflectionMethod $function
  * @param  array                               $codeCoverage
  */
 protected function __construct($scope, $function, &$codeCoverage = array())
 {
     $this->scope = $scope;
     $this->function = $function;
     $source = PHPUnit_Util_Class::getMethodSource($scope, $function->getName());
     if ($source !== FALSE) {
         $this->tokens = token_get_all('<?php' . $source . '?>');
         $this->parameters = $function->getNumberOfParameters();
         $this->calculateCCN();
         $this->calculateNPath();
         $this->calculateDependencies();
     }
     $this->setCoverage($codeCoverage);
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:21,代码来源:Function.php

示例7: __construct

 /**
  * Constructor.
  *
  * @param string $inClassName
  * @param string $inSourceFile
  * @param string $outClassName
  * @param string $outSourceFile
  * @since Method available since Release 3.4.0
  */
 public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '')
 {
     $this->inClassName = PHPUnit_Util_Class::parseFullyQualifiedClassName($inClassName);
     $this->outClassName = PHPUnit_Util_Class::parseFullyQualifiedClassName($outClassName);
     $this->inSourceFile = str_replace($this->inClassName['fullyQualifiedClassName'], $this->inClassName['className'], $inSourceFile);
     $this->outSourceFile = str_replace($this->outClassName['fullyQualifiedClassName'], $this->outClassName['className'], $outSourceFile);
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:16,代码来源:Skeleton.php

示例8: addTestFile

 /**
  * Wraps both <code>addTest()</code> and <code>addTestSuite</code>
  * as well as the separate import statements for the user's convenience.
  *
  * If the named file cannot be read or there are no new tests that can be
  * added, a <code>PHPUnit_Framework_Warning</code> will be created instead,
  * leaving the current test run untouched.
  *
  * @param  string  $filename
  * @param  boolean $syntaxCheck
  * @param  array   $phptOptions Array with ini settings for the php instance
  *                              run, key being the name if the setting,
  *                              value the ini value.
  * @throws InvalidArgumentException
  * @access public
  * @since  Method available since Release 2.3.0
  * @author Stefano F. Rausch <stefano@rausch-e.net>
  */
 public function addTestFile($filename, $syntaxCheck = TRUE, $phptOptions = array())
 {
     if (!is_string($filename)) {
         throw new InvalidArgumentException();
     }
     if (file_exists($filename) && substr($filename, -5) == '.phpt') {
         $this->addTest(new PHPUnit_Extensions_PhptTestCase($filename, $phptOptions));
         return;
     }
     if (!file_exists($filename)) {
         $includePaths = explode(PATH_SEPARATOR, get_include_path());
         foreach ($includePaths as $includePath) {
             $file = $includePath . DIRECTORY_SEPARATOR . $filename;
             if (file_exists($file)) {
                 $filename = $file;
                 break;
             }
         }
     }
     PHPUnit_Util_Class::collectStart();
     PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck);
     $newClasses = PHPUnit_Util_Class::collectEnd();
     $testsFound = FALSE;
     foreach ($newClasses as $className) {
         $class = new ReflectionClass($className);
         if (!$class->isAbstract()) {
             if ($class->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) {
                 $method = $class->getMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME);
                 if ($method->isStatic()) {
                     $this->addTest($method->invoke(NULL, $className));
                     $testsFound = TRUE;
                 }
             } else {
                 if ($class->implementsInterface('PHPUnit_Framework_Test')) {
                     $this->addTestSuite($class);
                     $testsFound = TRUE;
                 }
             }
         }
     }
     if (!$testsFound) {
         $this->addTest(new PHPUnit_Framework_Warning('No tests found in file "' . $filename . '".'));
     }
     $this->numTests = -1;
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:63,代码来源:TestSuite.php

示例9: processFunctions

 protected function processFunctions()
 {
     $functions = PHPUnit_Util_Class::getFunctionsInFile($this->getPath());
     if (count($functions) > 0 && !isset($this->classes['*'])) {
         $this->classes['*'] = array('methods' => array(), 'startLine' => 0, 'executableLines' => 0, 'executedLines' => 0);
     }
     foreach ($functions as $function) {
         $functionName = $function->getName();
         $functionStartLine = $function->getStartLine();
         $functionEndLine = $function->getEndLine();
         $this->classes['*']['methods'][$functionName] = array('startLine' => $functionStartLine, 'executableLines' => 0, 'executedLines' => 0);
         $this->startLines[$functionStartLine] =& $this->classes['*']['methods'][$functionName];
         $this->endLines[$functionEndLine] =& $this->classes['*']['methods'][$functionName];
         $this->numMethods++;
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:16,代码来源:File.php

示例10: generateConstructorCodeWithParentCall

 protected function generateConstructorCodeWithParentCall(ReflectionClass $class)
 {
     $constructor = $this->getConstructor($class);
     if ($constructor) {
         return sprintf("    public function __construct(%s) {\n" . "        \$args = func_get_args();\n" . "        \$this->invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;\n" . "        \$class = new ReflectionClass(\$this);\n" . "        \$class->getParentClass()->getConstructor()->invokeArgs(\$this, \$args);\n" . "    }\n\n", PHPUnit_Util_Class::getMethodParameters($constructor));
     } else {
         return $this->generateConstructorCode($class);
     }
 }
开发者ID:humansky,项目名称:qframe,代码行数:9,代码来源:Mock.php

示例11: startTestSuite

 /**
  * A testsuite started.
  *
  * @param  PHPUnit_Framework_TestSuite $suite
  * @since  Method available since Release 2.2.0
  */
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $testSuite = $this->document->createElement('testsuite');
     $testSuite->setAttribute('name', $suite->getName());
     if (class_exists($suite->getName(), FALSE)) {
         try {
             $class = new ReflectionClass($suite->getName());
             $testSuite->setAttribute('file', $class->getFileName());
             $packageInformation = PHPUnit_Util_Class::getPackageInformation($suite->getName(), $class->getDocComment());
             if (!empty($packageInformation['namespace'])) {
                 $testSuite->setAttribute('namespace', $packageInformation['namespace']);
             }
             if (!empty($packageInformation['fullPackage'])) {
                 $testSuite->setAttribute('fullPackage', $packageInformation['fullPackage']);
             }
             if (!empty($packageInformation['category'])) {
                 $testSuite->setAttribute('category', $packageInformation['category']);
             }
             if (!empty($packageInformation['package'])) {
                 $testSuite->setAttribute('package', $packageInformation['package']);
             }
             if (!empty($packageInformation['subpackage'])) {
                 $testSuite->setAttribute('subpackage', $packageInformation['subpackage']);
             }
         } catch (ReflectionException $e) {
         }
     }
     if ($this->testSuiteLevel > 0) {
         $this->testSuites[$this->testSuiteLevel]->appendChild($testSuite);
     } else {
         $this->root->appendChild($testSuite);
     }
     $this->testSuiteLevel++;
     $this->testSuites[$this->testSuiteLevel] = $testSuite;
     $this->testSuiteTests[$this->testSuiteLevel] = 0;
     $this->testSuiteAssertions[$this->testSuiteLevel] = 0;
     $this->testSuiteErrors[$this->testSuiteLevel] = 0;
     $this->testSuiteFailures[$this->testSuiteLevel] = 0;
     $this->testSuiteTimes[$this->testSuiteLevel] = 0;
 }
开发者ID:qcodo,项目名称:qcodo-website,代码行数:46,代码来源:JUnit.php

示例12: readAttribute

 /**
  * Returns the value of an attribute of a class or an object.
  * This also works for attributes that are declared protected or private.
  *
  * @param  mixed   $classOrObject
  * @param  string  $attributeName
  * @return mixed
  * @throws PHPUnit_Framework_Exception
  */
 public static function readAttribute($classOrObject, $attributeName)
 {
     if (!is_string($attributeName)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string');
     }
     if (is_string($classOrObject)) {
         if (!class_exists($classOrObject)) {
             throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name');
         }
         return PHPUnit_Util_Class::getStaticAttribute($classOrObject, $attributeName);
     } else {
         if (is_object($classOrObject)) {
             return PHPUnit_Util_Class::getObjectAttribute($classOrObject, $attributeName);
         } else {
             throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name or object');
         }
     }
 }
开发者ID:jeanCarloMachado,项目名称:challenges,代码行数:27,代码来源:Assert.php

示例13: run

 /**
  * Runs a TestCase.
  *
  * @param  PHPUnit_Framework_Test $test
  */
 public function run(PHPUnit_Framework_Test $test)
 {
     PHPUnit_Framework_Assert::resetCount();
     $error = FALSE;
     $failure = FALSE;
     $incomplete = FALSE;
     $skipped = FALSE;
     $this->startTest($test);
     $errorHandlerSet = FALSE;
     if ($this->convertErrorsToExceptions) {
         $oldErrorHandler = set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT);
         if ($oldErrorHandler === NULL) {
             $errorHandlerSet = TRUE;
         } else {
             restore_error_handler();
         }
     }
     if (self::$xdebugLoaded === NULL) {
         self::$xdebugLoaded = extension_loaded('xdebug');
         self::$useXdebug = self::$xdebugLoaded;
     }
     $useXdebug = self::$useXdebug && $this->codeCoverage !== NULL && !$test instanceof PHPUnit_Extensions_SeleniumTestCase && !$test instanceof PHPUnit_Framework_Warning;
     if ($useXdebug) {
         // We need to blacklist test source files when no whitelist is used.
         if (!$this->codeCoverage->filter()->hasWhitelist()) {
             $classes = PHPUnit_Util_Class::getHierarchy(get_class($test), TRUE);
             foreach ($classes as $class) {
                 $this->codeCoverage->filter()->addFileToBlacklist($class->getFileName());
             }
         }
         $this->codeCoverage->start($test);
     }
     PHP_Timer::start();
     try {
         if (!$test instanceof PHPUnit_Framework_Warning && $this->strictMode && extension_loaded('pcntl') && class_exists('PHP_Invoker')) {
             switch ($test->getSize()) {
                 case PHPUnit_Util_Test::SMALL:
                     $_timeout = $this->timeoutForSmallTests;
                     break;
                 case PHPUnit_Util_Test::MEDIUM:
                     $_timeout = $this->timeoutForMediumTests;
                     break;
                 case PHPUnit_Util_Test::LARGE:
                     $_timeout = $this->timeoutForLargeTests;
                     break;
             }
             $invoker = new PHP_Invoker();
             $invoker->invoke(array($test, 'runBare'), array(), $_timeout);
         } else {
             $test->runBare();
         }
     } catch (PHPUnit_Framework_AssertionFailedError $e) {
         $failure = TRUE;
         if ($e instanceof PHPUnit_Framework_IncompleteTestError) {
             $incomplete = TRUE;
         } else {
             if ($e instanceof PHPUnit_Framework_SkippedTestError) {
                 $skipped = TRUE;
             }
         }
     } catch (Exception $e) {
         $error = TRUE;
     }
     $time = PHP_Timer::stop();
     $test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
     if ($this->strictMode && $test->getNumAssertions() == 0) {
         $incomplete = TRUE;
     }
     if ($useXdebug) {
         try {
             $this->codeCoverage->stop(!$incomplete && !$skipped);
         } catch (PHP_CodeCoverage_Exception $cce) {
             $error = TRUE;
             if (!isset($e)) {
                 $e = $cce;
             }
         }
     }
     if ($errorHandlerSet === TRUE) {
         restore_error_handler();
     }
     if ($error === TRUE) {
         $this->addError($test, $e, $time);
     } else {
         if ($failure === TRUE) {
             $this->addFailure($test, $e, $time);
         } else {
             if ($this->strictMode && $test->getNumAssertions() == 0) {
                 $this->addFailure($test, new PHPUnit_Framework_IncompleteTestError('This test did not perform any assertions'), $time);
             } else {
                 if ($this->strictMode && $test->hasOutput()) {
                     $this->addFailure($test, new PHPUnit_Framework_OutputError(sprintf('This test printed output: %s', $test->getActualOutput())), $time);
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:qube81,项目名称:old-phpunit,代码行数:101,代码来源:TestResult.php

示例14: storeCodeCoverage

 /**
  * Stores code coverage information.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @param  integer                      $revision
  * @access public
  */
 public function storeCodeCoverage(PHPUnit_Framework_TestResult $result, $revision)
 {
     $codeCoverage = $result->getCodeCoverageInformation(FALSE, TRUE);
     $summary = PHPUnit_Util_CodeCoverage::getSummary($codeCoverage);
     $files = array_keys($summary);
     $commonPath = PHPUnit_Util_Filesystem::getCommonPath($files);
     $this->dbh->beginTransaction();
     foreach ($files as $file) {
         $filename = str_replace($commonPath, '', $file);
         $fileId = FALSE;
         $lines = file($file);
         $numLines = count($lines);
         $stmt = $this->dbh->query(sprintf('SELECT code_file_id
                FROM code_file
               WHERE code_file_name = "%s"
                 AND revision       = %d;', $filename, $revision));
         if ($stmt) {
             $fileId = (int) $stmt->fetchColumn();
         }
         unset($stmt);
         if ($fileId == 0) {
             $this->dbh->exec(sprintf('INSERT INTO code_file
                              (code_file_name, code_file_md5, revision)
                        VALUES("%s", "%s", %d);', $filename, md5_file($file), $revision));
             $fileId = $this->dbh->lastInsertId();
             $classes = PHPUnit_Util_Class::getClassesInFile($file, $commonPath);
             foreach ($classes as $class) {
                 $this->dbh->exec(sprintf('INSERT INTO code_class
                                  (code_file_id, code_class_name,
                                   code_class_start_line, code_class_end_line)
                            VALUES(%d, "%s", %d, %d);', $fileId, $class->getName(), $class->getStartLine(), $class->getEndLine()));
                 $classId = $this->dbh->lastInsertId();
                 foreach ($class->getMethods() as $method) {
                     if ($class->getName() != $method->getDeclaringClass()->getName()) {
                         continue;
                     }
                     $this->dbh->exec(sprintf('INSERT INTO code_method
                                      (code_class_id, code_method_name,
                                       code_method_start_line, code_method_end_line)
                                VALUES(%d, "%s", %d, %d);', $classId, $method->getName(), $method->getStartLine(), $method->getEndLine()));
                 }
             }
             $i = 1;
             foreach ($lines as $line) {
                 $this->dbh->exec(sprintf('INSERT INTO code_line
                                  (code_file_id, code_line_number, code_line,
                                   code_line_covered)
                            VALUES(%d, %d, "%s", %d);', $fileId, $i, trim($line), isset($summary[$file][$i]) ? $summary[$file][$i] : 0));
                 $i++;
             }
         }
         for ($lineNumber = 1; $lineNumber <= $numLines; $lineNumber++) {
             $coveringTests = PHPUnit_Util_CodeCoverage::getCoveringTests($codeCoverage, $file, $lineNumber);
             if (is_array($coveringTests)) {
                 $stmt = $this->dbh->query(sprintf('SELECT code_line_id, code_line_covered
                        FROM code_line
                       WHERE code_file_id     = %d
                         AND code_line_number = %d;', $fileId, $lineNumber));
                 $codeLineId = (int) $stmt->fetchColumn(0);
                 $oldCoverageFlag = (int) $stmt->fetchColumn(1);
                 unset($stmt);
                 $newCoverageFlag = $summary[$file][$lineNumber];
                 if ($oldCoverageFlag == 0 && $newCoverageFlag != 0 || $oldCoverageFlag < 0 && $newCoverageFlag > 0) {
                     $this->dbh->exec(sprintf('UPDATE code_line
                             SET code_line_covered = %d
                           WHERE code_line_id      = %d;', $newCoverageFlag, $codeLineId));
                 }
                 foreach ($coveringTests as $test) {
                     $this->dbh->exec(sprintf('INSERT INTO code_coverage
                                      (test_id, code_line_id)
                                VALUES(%d, %d);', $test->__db_id, $codeLineId));
                 }
             }
         }
     }
     foreach ($result->topTestSuite() as $test) {
         if ($test instanceof PHPUnit_Framework_TestCase) {
             $stmt = $this->dbh->query(sprintf('SELECT code_method.code_method_id
                    FROM code_class, code_method
                   WHERE code_class.code_class_id     = code_method.code_class_id
                     AND code_class.code_class_name   = "%s"
                     AND code_method.code_method_name = "%s";', get_class($test), $test->getName()));
             $methodId = (int) $stmt->fetchColumn();
             unset($stmt);
             $this->dbh->exec(sprintf('UPDATE test
                     SET code_method_id = %d
                   WHERE test_id = %d;', $methodId, $test->__db_id));
         }
     }
     $this->dbh->commit();
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:98,代码来源:Database.php

示例15: __construct

 /**
  * Constructor.
  *
  * @param  string $filename
  * @param  array  $codeCoverage
  * @throws RuntimeException
  */
 protected function __construct($filename, &$codeCoverage = array())
 {
     if (!file_exists($filename)) {
         throw new RuntimeException(sprintf('File "%s" not found.', $filename));
     }
     $this->filename = $filename;
     $this->lines = file($filename);
     $this->tokens = token_get_all(file_get_contents($filename));
     $this->countLines();
     $this->setCoverage($codeCoverage);
     foreach (PHPUnit_Util_Class::getClassesInFile($filename) as $class) {
         $this->classes[$class->getName()] = PHPUnit_Util_Metrics_Class::factory($class, $codeCoverage);
     }
     foreach (PHPUnit_Util_Class::getFunctionsInFile($filename) as $function) {
         $this->functions[$function->getName()] = PHPUnit_Util_Metrics_Function::factory($function, $codeCoverage);
     }
 }
开发者ID:cjmi,项目名称:miniblog,代码行数:24,代码来源:File.php


注:本文中的PHPUnit_Util_Class类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。