PageRenderTime 60ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/vendor/phpunit/phpunit/src/Framework/TestCase.php

https://gitlab.com/jhonn/rest
PHP | 2004 lines | 1010 code | 240 blank | 754 comment | 120 complexity | 2f73c9f0f686ec6d9b5ef8abf3d8581c MD5 | raw file
Possible License(s): BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * PHPUnit
  4. *
  5. * Copyright (c) 2001-2014, Sebastian Bergmann <sebastian@phpunit.de>.
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * * Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * * Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * * Neither the name of Sebastian Bergmann nor the names of his
  21. * contributors may be used to endorse or promote products derived
  22. * from this software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  27. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  28. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  29. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  30. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  34. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  35. * POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. * @package PHPUnit
  38. * @subpackage Framework
  39. * @author Sebastian Bergmann <sebastian@phpunit.de>
  40. * @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
  41. * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
  42. * @link http://www.phpunit.de/
  43. * @since File available since Release 2.0.0
  44. */
  45. use SebastianBergmann\GlobalState\Snapshot;
  46. use SebastianBergmann\GlobalState\Restorer;
  47. use SebastianBergmann\GlobalState\Blacklist;
  48. use SebastianBergmann\Exporter\Context;
  49. use SebastianBergmann\Exporter\Exporter;
  50. /**
  51. * A TestCase defines the fixture to run multiple tests.
  52. *
  53. * To define a TestCase
  54. *
  55. * 1) Implement a subclass of PHPUnit_Framework_TestCase.
  56. * 2) Define instance variables that store the state of the fixture.
  57. * 3) Initialize the fixture state by overriding setUp().
  58. * 4) Clean-up after a test by overriding tearDown().
  59. *
  60. * Each test runs in its own fixture so there can be no side effects
  61. * among test runs.
  62. *
  63. * Here is an example:
  64. *
  65. * <code>
  66. * <?php
  67. * class MathTest extends PHPUnit_Framework_TestCase
  68. * {
  69. * public $value1;
  70. * public $value2;
  71. *
  72. * protected function setUp()
  73. * {
  74. * $this->value1 = 2;
  75. * $this->value2 = 3;
  76. * }
  77. * }
  78. * ?>
  79. * </code>
  80. *
  81. * For each test implement a method which interacts with the fixture.
  82. * Verify the expected results with assertions specified by calling
  83. * assert with a boolean.
  84. *
  85. * <code>
  86. * <?php
  87. * public function testPass()
  88. * {
  89. * $this->assertTrue($this->value1 + $this->value2 == 5);
  90. * }
  91. * ?>
  92. * </code>
  93. *
  94. * @package PHPUnit
  95. * @subpackage Framework
  96. * @author Sebastian Bergmann <sebastian@phpunit.de>
  97. * @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
  98. * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
  99. * @link http://www.phpunit.de/
  100. * @since Class available since Release 2.0.0
  101. */
  102. abstract class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing
  103. {
  104. /**
  105. * Enable or disable the backup and restoration of the $GLOBALS array.
  106. * Overwrite this attribute in a child class of TestCase.
  107. * Setting this attribute in setUp() has no effect!
  108. *
  109. * @var boolean
  110. */
  111. protected $backupGlobals = null;
  112. /**
  113. * @var array
  114. */
  115. protected $backupGlobalsBlacklist = array();
  116. /**
  117. * Enable or disable the backup and restoration of static attributes.
  118. * Overwrite this attribute in a child class of TestCase.
  119. * Setting this attribute in setUp() has no effect!
  120. *
  121. * @var boolean
  122. */
  123. protected $backupStaticAttributes = null;
  124. /**
  125. * @var array
  126. */
  127. protected $backupStaticAttributesBlacklist = array();
  128. /**
  129. * Whether or not this test is to be run in a separate PHP process.
  130. *
  131. * @var boolean
  132. */
  133. protected $runTestInSeparateProcess = null;
  134. /**
  135. * Whether or not this test should preserve the global state when
  136. * running in a separate PHP process.
  137. *
  138. * @var boolean
  139. */
  140. protected $preserveGlobalState = true;
  141. /**
  142. * Whether or not this test is running in a separate PHP process.
  143. *
  144. * @var boolean
  145. */
  146. private $inIsolation = false;
  147. /**
  148. * @var array
  149. */
  150. private $data = array();
  151. /**
  152. * @var string
  153. */
  154. private $dataName = '';
  155. /**
  156. * @var boolean
  157. */
  158. private $useErrorHandler = null;
  159. /**
  160. * The name of the expected Exception.
  161. *
  162. * @var mixed
  163. */
  164. private $expectedException = null;
  165. /**
  166. * The message of the expected Exception.
  167. *
  168. * @var string
  169. */
  170. private $expectedExceptionMessage = '';
  171. /**
  172. * The regex pattern to validate the expected Exception message.
  173. *
  174. * @var string
  175. */
  176. private $expectedExceptionMessageRegExp = '';
  177. /**
  178. * The code of the expected Exception.
  179. *
  180. * @var integer
  181. */
  182. private $expectedExceptionCode;
  183. /**
  184. * The name of the test case.
  185. *
  186. * @var string
  187. */
  188. private $name = null;
  189. /**
  190. * @var array
  191. */
  192. private $dependencies = array();
  193. /**
  194. * @var array
  195. */
  196. private $dependencyInput = array();
  197. /**
  198. * @var array
  199. */
  200. private $iniSettings = array();
  201. /**
  202. * @var array
  203. */
  204. private $locale = array();
  205. /**
  206. * @var array
  207. */
  208. private $mockObjects = array();
  209. /**
  210. * @var array
  211. */
  212. private $mockObjectGenerator = null;
  213. /**
  214. * @var integer
  215. */
  216. private $status;
  217. /**
  218. * @var string
  219. */
  220. private $statusMessage = '';
  221. /**
  222. * @var integer
  223. */
  224. private $numAssertions = 0;
  225. /**
  226. * @var PHPUnit_Framework_TestResult
  227. */
  228. private $result;
  229. /**
  230. * @var mixed
  231. */
  232. private $testResult;
  233. /**
  234. * @var string
  235. */
  236. private $output = '';
  237. /**
  238. * @var string
  239. */
  240. private $outputExpectedRegex = null;
  241. /**
  242. * @var string
  243. */
  244. private $outputExpectedString = null;
  245. /**
  246. * @var mixed
  247. */
  248. private $outputCallback = false;
  249. /**
  250. * @var boolean
  251. */
  252. private $outputBufferingActive = false;
  253. /**
  254. * @var integer
  255. */
  256. private $outputBufferingLevel;
  257. /**
  258. * @var SebastianBergmann\GlobalState\Snapshot
  259. */
  260. private $snapshot;
  261. /**
  262. * Constructs a test case with the given name.
  263. *
  264. * @param string $name
  265. * @param array $data
  266. * @param string $dataName
  267. */
  268. public function __construct($name = null, array $data = array(), $dataName = '')
  269. {
  270. if ($name !== null) {
  271. $this->setName($name);
  272. }
  273. $this->data = $data;
  274. $this->dataName = $dataName;
  275. }
  276. /**
  277. * Returns a string representation of the test case.
  278. *
  279. * @return string
  280. */
  281. public function toString()
  282. {
  283. $class = new ReflectionClass($this);
  284. $buffer = sprintf(
  285. '%s::%s',
  286. $class->name,
  287. $this->getName(false)
  288. );
  289. return $buffer . $this->getDataSetAsString();
  290. }
  291. /**
  292. * Counts the number of test cases executed by run(TestResult result).
  293. *
  294. * @return integer
  295. */
  296. public function count()
  297. {
  298. return 1;
  299. }
  300. /**
  301. * Returns the annotations for this test.
  302. *
  303. * @return array
  304. * @since Method available since Release 3.4.0
  305. */
  306. public function getAnnotations()
  307. {
  308. return PHPUnit_Util_Test::parseTestMethodAnnotations(
  309. get_class($this),
  310. $this->name
  311. );
  312. }
  313. /**
  314. * Gets the name of a TestCase.
  315. *
  316. * @param boolean $withDataSet
  317. * @return string
  318. */
  319. public function getName($withDataSet = true)
  320. {
  321. if ($withDataSet) {
  322. return $this->name . $this->getDataSetAsString(false);
  323. } else {
  324. return $this->name;
  325. }
  326. }
  327. /**
  328. * Returns the size of the test.
  329. *
  330. * @return integer
  331. * @since Method available since Release 3.6.0
  332. */
  333. public function getSize()
  334. {
  335. return PHPUnit_Util_Test::getSize(
  336. get_class($this),
  337. $this->getName(false)
  338. );
  339. }
  340. /**
  341. * @return string
  342. * @since Method available since Release 3.6.0
  343. */
  344. public function getActualOutput()
  345. {
  346. if (!$this->outputBufferingActive) {
  347. return $this->output;
  348. } else {
  349. return ob_get_contents();
  350. }
  351. }
  352. /**
  353. * @return boolean
  354. * @since Method available since Release 3.6.0
  355. */
  356. public function hasOutput()
  357. {
  358. if (strlen($this->output) === 0) {
  359. return false;
  360. }
  361. if ($this->hasExpectationOnOutput()) {
  362. return false;
  363. }
  364. return true;
  365. }
  366. /**
  367. * @param string $expectedRegex
  368. * @since Method available since Release 3.6.0
  369. * @throws PHPUnit_Framework_Exception
  370. */
  371. public function expectOutputRegex($expectedRegex)
  372. {
  373. if ($this->outputExpectedString !== null) {
  374. throw new PHPUnit_Framework_Exception;
  375. }
  376. if (is_string($expectedRegex) || is_null($expectedRegex)) {
  377. $this->outputExpectedRegex = $expectedRegex;
  378. }
  379. }
  380. /**
  381. * @param string $expectedString
  382. * @since Method available since Release 3.6.0
  383. */
  384. public function expectOutputString($expectedString)
  385. {
  386. if ($this->outputExpectedRegex !== null) {
  387. throw new PHPUnit_Framework_Exception;
  388. }
  389. if (is_string($expectedString) || is_null($expectedString)) {
  390. $this->outputExpectedString = $expectedString;
  391. }
  392. }
  393. /**
  394. * @return bool
  395. * @since Method available since Release 3.6.5
  396. * @deprecated
  397. */
  398. public function hasPerformedExpectationsOnOutput()
  399. {
  400. return $this->hasExpectationOnOutput();
  401. }
  402. /**
  403. * @return bool
  404. * @since Method available since Release 4.3.3
  405. */
  406. public function hasExpectationOnOutput()
  407. {
  408. return is_string($this->outputExpectedString) || is_string($this->outputExpectedRegex);
  409. }
  410. /**
  411. * @return string
  412. * @since Method available since Release 3.2.0
  413. */
  414. public function getExpectedException()
  415. {
  416. return $this->expectedException;
  417. }
  418. /**
  419. * @param mixed $exceptionName
  420. * @param string $exceptionMessage
  421. * @param integer $exceptionCode
  422. * @since Method available since Release 3.2.0
  423. */
  424. public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = null)
  425. {
  426. $this->expectedException = $exceptionName;
  427. $this->expectedExceptionMessage = $exceptionMessage;
  428. $this->expectedExceptionCode = $exceptionCode;
  429. }
  430. /**
  431. * @param mixed $exceptionName
  432. * @param string $exceptionMessageRegExp
  433. * @param integer $exceptionCode
  434. * @since Method available since Release 4.3.0
  435. */
  436. public function setExpectedExceptionRegExp($exceptionName, $exceptionMessageRegExp = '', $exceptionCode = null)
  437. {
  438. $this->expectedException = $exceptionName;
  439. $this->expectedExceptionMessageRegExp = $exceptionMessageRegExp;
  440. $this->expectedExceptionCode = $exceptionCode;
  441. }
  442. /**
  443. * @since Method available since Release 3.4.0
  444. */
  445. protected function setExpectedExceptionFromAnnotation()
  446. {
  447. try {
  448. $expectedException = PHPUnit_Util_Test::getExpectedException(
  449. get_class($this),
  450. $this->name
  451. );
  452. if ($expectedException !== false) {
  453. $this->setExpectedException(
  454. $expectedException['class'],
  455. $expectedException['message'],
  456. $expectedException['code']
  457. );
  458. if (!empty($expectedException['message_regex'])) {
  459. $this->setExpectedExceptionRegExp(
  460. $expectedException['class'],
  461. $expectedException['message_regex'],
  462. $expectedException['code']
  463. );
  464. }
  465. }
  466. } catch (ReflectionException $e) {
  467. }
  468. }
  469. /**
  470. * @param boolean $useErrorHandler
  471. * @since Method available since Release 3.4.0
  472. */
  473. public function setUseErrorHandler($useErrorHandler)
  474. {
  475. $this->useErrorHandler = $useErrorHandler;
  476. }
  477. /**
  478. * @since Method available since Release 3.4.0
  479. */
  480. protected function setUseErrorHandlerFromAnnotation()
  481. {
  482. try {
  483. $useErrorHandler = PHPUnit_Util_Test::getErrorHandlerSettings(
  484. get_class($this),
  485. $this->name
  486. );
  487. if ($useErrorHandler !== null) {
  488. $this->setUseErrorHandler($useErrorHandler);
  489. }
  490. } catch (ReflectionException $e) {
  491. }
  492. }
  493. /**
  494. * @since Method available since Release 3.6.0
  495. */
  496. protected function checkRequirements()
  497. {
  498. if (!$this->name || !method_exists($this, $this->name)) {
  499. return;
  500. }
  501. $missingRequirements = PHPUnit_Util_Test::getMissingRequirements(
  502. get_class($this),
  503. $this->name
  504. );
  505. if ($missingRequirements) {
  506. $this->markTestSkipped(implode(PHP_EOL, $missingRequirements));
  507. }
  508. }
  509. /**
  510. * Returns the status of this test.
  511. *
  512. * @return integer
  513. * @since Method available since Release 3.1.0
  514. */
  515. public function getStatus()
  516. {
  517. return $this->status;
  518. }
  519. /**
  520. * Returns the status message of this test.
  521. *
  522. * @return string
  523. * @since Method available since Release 3.3.0
  524. */
  525. public function getStatusMessage()
  526. {
  527. return $this->statusMessage;
  528. }
  529. /**
  530. * Returns whether or not this test has failed.
  531. *
  532. * @return boolean
  533. * @since Method available since Release 3.0.0
  534. */
  535. public function hasFailed()
  536. {
  537. $status = $this->getStatus();
  538. return $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE ||
  539. $status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR;
  540. }
  541. /**
  542. * Runs the test case and collects the results in a TestResult object.
  543. * If no TestResult object is passed a new one will be created.
  544. *
  545. * @param PHPUnit_Framework_TestResult $result
  546. * @return PHPUnit_Framework_TestResult
  547. * @throws PHPUnit_Framework_Exception
  548. */
  549. public function run(PHPUnit_Framework_TestResult $result = null)
  550. {
  551. if ($result === null) {
  552. $result = $this->createResult();
  553. }
  554. if (!$this instanceof PHPUnit_Framework_Warning) {
  555. $this->setTestResultObject($result);
  556. $this->setUseErrorHandlerFromAnnotation();
  557. }
  558. if ($this->useErrorHandler !== null) {
  559. $oldErrorHandlerSetting = $result->getConvertErrorsToExceptions();
  560. $result->convertErrorsToExceptions($this->useErrorHandler);
  561. }
  562. if (!$this instanceof PHPUnit_Framework_Warning && !$this->handleDependencies()) {
  563. return;
  564. }
  565. if ($this->runTestInSeparateProcess === true &&
  566. $this->inIsolation !== true &&
  567. !$this instanceof PHPUnit_Extensions_SeleniumTestCase &&
  568. !$this instanceof PHPUnit_Extensions_PhptTestCase) {
  569. $class = new ReflectionClass($this);
  570. $template = new Text_Template(
  571. __DIR__ . '/../Util/PHP/Template/TestCaseMethod.tpl'
  572. );
  573. if ($this->preserveGlobalState) {
  574. $constants = PHPUnit_Util_GlobalState::getConstantsAsString();
  575. $globals = PHPUnit_Util_GlobalState::getGlobalsAsString();
  576. $includedFiles = PHPUnit_Util_GlobalState::getIncludedFilesAsString();
  577. $iniSettings = PHPUnit_Util_GlobalState::getIniSettingsAsString();
  578. } else {
  579. $constants = '';
  580. if (!empty($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
  581. $globals = '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = ' . var_export($GLOBALS['__PHPUNIT_BOOTSTRAP'], true) . ";\n";
  582. } else {
  583. $globals = '';
  584. }
  585. $includedFiles = '';
  586. $iniSettings = '';
  587. }
  588. $coverage = $result->getCollectCodeCoverageInformation() ? 'true' : 'false';
  589. $isStrictAboutTestsThatDoNotTestAnything = $result->isStrictAboutTestsThatDoNotTestAnything() ? 'true' : 'false';
  590. $isStrictAboutOutputDuringTests = $result->isStrictAboutOutputDuringTests() ? 'true' : 'false';
  591. $isStrictAboutTestSize = $result->isStrictAboutTestSize() ? 'true' : 'false';
  592. $isStrictAboutTodoAnnotatedTests = $result->isStrictAboutTodoAnnotatedTests() ? 'true' : 'false';
  593. if (defined('PHPUNIT_COMPOSER_INSTALL')) {
  594. $composerAutoload = var_export(PHPUNIT_COMPOSER_INSTALL, true);
  595. } else {
  596. $composerAutoload = '\'\'';
  597. }
  598. if (defined('__PHPUNIT_PHAR__')) {
  599. $phar = var_export(__PHPUNIT_PHAR__, true);
  600. } else {
  601. $phar = '\'\'';
  602. }
  603. $data = var_export(serialize($this->data), true);
  604. $dataName = var_export($this->dataName, true);
  605. $dependencyInput = var_export(serialize($this->dependencyInput), true);
  606. $includePath = var_export(get_include_path(), true);
  607. // must do these fixes because TestCaseMethod.tpl has unserialize('{data}') in it, and we can't break BC
  608. // the lines above used to use addcslashes() rather than var_export(), which breaks null byte escape sequences
  609. $data = "'." . $data . ".'";
  610. $dataName = "'.(" . $dataName . ").'";
  611. $dependencyInput = "'." . $dependencyInput . ".'";
  612. $includePath = "'." . $includePath . ".'";
  613. $template->setVar(
  614. array(
  615. 'composerAutoload' => $composerAutoload,
  616. 'phar' => $phar,
  617. 'filename' => $class->getFileName(),
  618. 'className' => $class->getName(),
  619. 'methodName' => $this->name,
  620. 'collectCodeCoverageInformation' => $coverage,
  621. 'data' => $data,
  622. 'dataName' => $dataName,
  623. 'dependencyInput' => $dependencyInput,
  624. 'constants' => $constants,
  625. 'globals' => $globals,
  626. 'include_path' => $includePath,
  627. 'included_files' => $includedFiles,
  628. 'iniSettings' => $iniSettings,
  629. 'isStrictAboutTestsThatDoNotTestAnything' => $isStrictAboutTestsThatDoNotTestAnything,
  630. 'isStrictAboutOutputDuringTests' => $isStrictAboutOutputDuringTests,
  631. 'isStrictAboutTestSize' => $isStrictAboutTestSize,
  632. 'isStrictAboutTodoAnnotatedTests' => $isStrictAboutTodoAnnotatedTests
  633. )
  634. );
  635. $this->prepareTemplate($template);
  636. $php = PHPUnit_Util_PHP::factory();
  637. $php->runTestJob($template->render(), $this, $result);
  638. } else {
  639. $result->run($this);
  640. }
  641. if ($this->useErrorHandler !== null) {
  642. $result->convertErrorsToExceptions($oldErrorHandlerSetting);
  643. }
  644. $this->result = null;
  645. return $result;
  646. }
  647. /**
  648. * Runs the bare test sequence.
  649. */
  650. public function runBare()
  651. {
  652. $this->numAssertions = 0;
  653. $this->snapshotGlobalState();
  654. $this->startOutputBuffering();
  655. clearstatcache();
  656. $currentWorkingDirectory = getcwd();
  657. $hookMethods = PHPUnit_Util_Test::getHookMethods(get_class($this));
  658. try {
  659. $hasMetRequirements = false;
  660. $this->checkRequirements();
  661. $hasMetRequirements = true;
  662. if ($this->inIsolation) {
  663. foreach ($hookMethods['beforeClass'] as $method) {
  664. $this->$method();
  665. }
  666. }
  667. $this->setExpectedExceptionFromAnnotation();
  668. foreach ($hookMethods['before'] as $method) {
  669. $this->$method();
  670. }
  671. $this->assertPreConditions();
  672. $this->testResult = $this->runTest();
  673. $this->verifyMockObjects();
  674. $this->assertPostConditions();
  675. $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
  676. } catch (PHPUnit_Framework_IncompleteTest $e) {
  677. $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE;
  678. $this->statusMessage = $e->getMessage();
  679. } catch (PHPUnit_Framework_SkippedTest $e) {
  680. $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED;
  681. $this->statusMessage = $e->getMessage();
  682. } catch (PHPUnit_Framework_AssertionFailedError $e) {
  683. $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE;
  684. $this->statusMessage = $e->getMessage();
  685. } catch (Exception $e) {
  686. $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_ERROR;
  687. $this->statusMessage = $e->getMessage();
  688. }
  689. // Clean up the mock objects.
  690. $this->mockObjects = array();
  691. // Tear down the fixture. An exception raised in tearDown() will be
  692. // caught and passed on when no exception was raised before.
  693. try {
  694. if ($hasMetRequirements) {
  695. foreach ($hookMethods['after'] as $method) {
  696. $this->$method();
  697. }
  698. if ($this->inIsolation) {
  699. foreach ($hookMethods['afterClass'] as $method) {
  700. $this->$method();
  701. }
  702. }
  703. }
  704. } catch (Exception $_e) {
  705. if (!isset($e)) {
  706. $e = $_e;
  707. }
  708. }
  709. try {
  710. $this->stopOutputBuffering();
  711. } catch (PHPUnit_Framework_RiskyTestError $_e) {
  712. if (!isset($e)) {
  713. $e = $_e;
  714. }
  715. }
  716. clearstatcache();
  717. if ($currentWorkingDirectory != getcwd()) {
  718. chdir($currentWorkingDirectory);
  719. }
  720. $this->restoreGlobalState();
  721. // Clean up INI settings.
  722. foreach ($this->iniSettings as $varName => $oldValue) {
  723. ini_set($varName, $oldValue);
  724. }
  725. $this->iniSettings = array();
  726. // Clean up locale settings.
  727. foreach ($this->locale as $category => $locale) {
  728. setlocale($category, $locale);
  729. }
  730. // Perform assertion on output.
  731. if (!isset($e)) {
  732. try {
  733. if ($this->outputExpectedRegex !== null) {
  734. $this->assertRegExp($this->outputExpectedRegex, $this->output);
  735. } elseif ($this->outputExpectedString !== null) {
  736. $this->assertEquals($this->outputExpectedString, $this->output);
  737. }
  738. } catch (Exception $_e) {
  739. $e = $_e;
  740. }
  741. }
  742. // Workaround for missing "finally".
  743. if (isset($e)) {
  744. $this->onNotSuccessfulTest($e);
  745. }
  746. }
  747. /**
  748. * Override to run the test and assert its state.
  749. *
  750. * @return mixed
  751. * @throws Exception|PHPUnit_Framework_Exception
  752. * @throws PHPUnit_Framework_Exception
  753. */
  754. protected function runTest()
  755. {
  756. if ($this->name === null) {
  757. throw new PHPUnit_Framework_Exception(
  758. 'PHPUnit_Framework_TestCase::$name must not be null.'
  759. );
  760. }
  761. try {
  762. $class = new ReflectionClass($this);
  763. $method = $class->getMethod($this->name);
  764. } catch (ReflectionException $e) {
  765. $this->fail($e->getMessage());
  766. }
  767. try {
  768. $testResult = $method->invokeArgs(
  769. $this,
  770. array_merge($this->data, $this->dependencyInput)
  771. );
  772. } catch (Exception $e) {
  773. $checkException = false;
  774. if (is_string($this->expectedException)) {
  775. $checkException = true;
  776. if ($e instanceof PHPUnit_Framework_Exception) {
  777. $checkException = false;
  778. }
  779. $reflector = new ReflectionClass($this->expectedException);
  780. if ($this->expectedException == 'PHPUnit_Framework_Exception' ||
  781. $reflector->isSubclassOf('PHPUnit_Framework_Exception')) {
  782. $checkException = true;
  783. }
  784. }
  785. if ($checkException) {
  786. $this->assertThat(
  787. $e,
  788. new PHPUnit_Framework_Constraint_Exception(
  789. $this->expectedException
  790. )
  791. );
  792. if (is_string($this->expectedExceptionMessage) &&
  793. !empty($this->expectedExceptionMessage)) {
  794. $this->assertThat(
  795. $e,
  796. new PHPUnit_Framework_Constraint_ExceptionMessage(
  797. $this->expectedExceptionMessage
  798. )
  799. );
  800. }
  801. if (is_string($this->expectedExceptionMessageRegExp) &&
  802. !empty($this->expectedExceptionMessageRegExp)) {
  803. $this->assertThat(
  804. $e,
  805. new PHPUnit_Framework_Constraint_ExceptionMessageRegExp(
  806. $this->expectedExceptionMessageRegExp
  807. )
  808. );
  809. }
  810. if ($this->expectedExceptionCode !== null) {
  811. $this->assertThat(
  812. $e,
  813. new PHPUnit_Framework_Constraint_ExceptionCode(
  814. $this->expectedExceptionCode
  815. )
  816. );
  817. }
  818. return;
  819. } else {
  820. throw $e;
  821. }
  822. }
  823. if ($this->expectedException !== null) {
  824. $this->assertThat(
  825. null,
  826. new PHPUnit_Framework_Constraint_Exception(
  827. $this->expectedException
  828. )
  829. );
  830. }
  831. return $testResult;
  832. }
  833. /**
  834. * Verifies the mock object expectations.
  835. *
  836. * @since Method available since Release 3.5.0
  837. */
  838. protected function verifyMockObjects()
  839. {
  840. foreach ($this->mockObjects as $mockObject) {
  841. if ($mockObject->__phpunit_hasMatchers()) {
  842. $this->numAssertions++;
  843. }
  844. $mockObject->__phpunit_verify();
  845. }
  846. }
  847. /**
  848. * Sets the name of a TestCase.
  849. *
  850. * @param string
  851. */
  852. public function setName($name)
  853. {
  854. $this->name = $name;
  855. }
  856. /**
  857. * Sets the dependencies of a TestCase.
  858. *
  859. * @param array $dependencies
  860. * @since Method available since Release 3.4.0
  861. */
  862. public function setDependencies(array $dependencies)
  863. {
  864. $this->dependencies = $dependencies;
  865. }
  866. /**
  867. * Returns true if the tests has dependencies
  868. *
  869. * @return boolean
  870. * @since Method available since Release 4.0.0
  871. */
  872. public function hasDependencies()
  873. {
  874. return count($this->dependencies) > 0;
  875. }
  876. /**
  877. * Sets
  878. *
  879. * @param array $dependencyInput
  880. * @since Method available since Release 3.4.0
  881. */
  882. public function setDependencyInput(array $dependencyInput)
  883. {
  884. $this->dependencyInput = $dependencyInput;
  885. }
  886. /**
  887. * Calling this method in setUp() has no effect!
  888. *
  889. * @param boolean $backupGlobals
  890. * @since Method available since Release 3.3.0
  891. */
  892. public function setBackupGlobals($backupGlobals)
  893. {
  894. if (is_null($this->backupGlobals) && is_bool($backupGlobals)) {
  895. $this->backupGlobals = $backupGlobals;
  896. }
  897. }
  898. /**
  899. * Calling this method in setUp() has no effect!
  900. *
  901. * @param boolean $backupStaticAttributes
  902. * @since Method available since Release 3.4.0
  903. */
  904. public function setBackupStaticAttributes($backupStaticAttributes)
  905. {
  906. if (is_null($this->backupStaticAttributes) &&
  907. is_bool($backupStaticAttributes)) {
  908. $this->backupStaticAttributes = $backupStaticAttributes;
  909. }
  910. }
  911. /**
  912. * @param boolean $runTestInSeparateProcess
  913. * @throws PHPUnit_Framework_Exception
  914. * @since Method available since Release 3.4.0
  915. */
  916. public function setRunTestInSeparateProcess($runTestInSeparateProcess)
  917. {
  918. if (is_bool($runTestInSeparateProcess)) {
  919. if ($this->runTestInSeparateProcess === null) {
  920. $this->runTestInSeparateProcess = $runTestInSeparateProcess;
  921. }
  922. } else {
  923. throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean');
  924. }
  925. }
  926. /**
  927. * @param boolean $preserveGlobalState
  928. * @throws PHPUnit_Framework_Exception
  929. * @since Method available since Release 3.4.0
  930. */
  931. public function setPreserveGlobalState($preserveGlobalState)
  932. {
  933. if (is_bool($preserveGlobalState)) {
  934. $this->preserveGlobalState = $preserveGlobalState;
  935. } else {
  936. throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean');
  937. }
  938. }
  939. /**
  940. * @param boolean $inIsolation
  941. * @throws PHPUnit_Framework_Exception
  942. * @since Method available since Release 3.4.0
  943. */
  944. public function setInIsolation($inIsolation)
  945. {
  946. if (is_bool($inIsolation)) {
  947. $this->inIsolation = $inIsolation;
  948. } else {
  949. throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean');
  950. }
  951. }
  952. /**
  953. * @return boolean
  954. * @since Method available since Release 4.3.0
  955. */
  956. public function isInIsolation()
  957. {
  958. return $this->inIsolation;
  959. }
  960. /**
  961. * @return mixed
  962. * @since Method available since Release 3.4.0
  963. */
  964. public function getResult()
  965. {
  966. return $this->testResult;
  967. }
  968. /**
  969. * @param mixed $result
  970. * @since Method available since Release 3.4.0
  971. */
  972. public function setResult($result)
  973. {
  974. $this->testResult = $result;
  975. }
  976. /**
  977. * @param callable $callback
  978. * @throws PHPUnit_Framework_Exception
  979. * @since Method available since Release 3.6.0
  980. */
  981. public function setOutputCallback($callback)
  982. {
  983. if (!is_callable($callback)) {
  984. throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'callback');
  985. }
  986. $this->outputCallback = $callback;
  987. }
  988. /**
  989. * @return PHPUnit_Framework_TestResult
  990. * @since Method available since Release 3.5.7
  991. */
  992. public function getTestResultObject()
  993. {
  994. return $this->result;
  995. }
  996. /**
  997. * @param PHPUnit_Framework_TestResult $result
  998. * @since Method available since Release 3.6.0
  999. */
  1000. public function setTestResultObject(PHPUnit_Framework_TestResult $result)
  1001. {
  1002. $this->result = $result;
  1003. }
  1004. /**
  1005. * This method is a wrapper for the ini_set() function that automatically
  1006. * resets the modified php.ini setting to its original value after the
  1007. * test is run.
  1008. *
  1009. * @param string $varName
  1010. * @param string $newValue
  1011. * @throws PHPUnit_Framework_Exception
  1012. * @since Method available since Release 3.0.0
  1013. */
  1014. protected function iniSet($varName, $newValue)
  1015. {
  1016. if (!is_string($varName)) {
  1017. throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
  1018. }
  1019. $currentValue = ini_set($varName, $newValue);
  1020. if ($currentValue !== false) {
  1021. $this->iniSettings[$varName] = $currentValue;
  1022. } else {
  1023. throw new PHPUnit_Framework_Exception(
  1024. sprintf(
  1025. 'INI setting "%s" could not be set to "%s".',
  1026. $varName,
  1027. $newValue
  1028. )
  1029. );
  1030. }
  1031. }
  1032. /**
  1033. * This method is a wrapper for the setlocale() function that automatically
  1034. * resets the locale to its original value after the test is run.
  1035. *
  1036. * @param integer $category
  1037. * @param string $locale
  1038. * @throws PHPUnit_Framework_Exception
  1039. * @since Method available since Release 3.1.0
  1040. */
  1041. protected function setLocale()
  1042. {
  1043. $args = func_get_args();
  1044. if (count($args) < 2) {
  1045. throw new PHPUnit_Framework_Exception;
  1046. }
  1047. $category = $args[0];
  1048. $locale = $args[1];
  1049. $categories = array(
  1050. LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
  1051. );
  1052. if (defined('LC_MESSAGES')) {
  1053. $categories[] = LC_MESSAGES;
  1054. }
  1055. if (!in_array($category, $categories)) {
  1056. throw new PHPUnit_Framework_Exception;
  1057. }
  1058. if (!is_array($locale) && !is_string($locale)) {
  1059. throw new PHPUnit_Framework_Exception;
  1060. }
  1061. $this->locale[$category] = setlocale($category, null);
  1062. $result = call_user_func_array( 'setlocale', $args );
  1063. if ($result === false) {
  1064. throw new PHPUnit_Framework_Exception(
  1065. 'The locale functionality is not implemented on your platform, ' .
  1066. 'the specified locale does not exist or the category name is ' .
  1067. 'invalid.'
  1068. );
  1069. }
  1070. }
  1071. /**
  1072. * Returns a mock object for the specified class.
  1073. *
  1074. * @param string $originalClassName Name of the class to mock.
  1075. * @param array|null $methods When provided, only methods whose names are in the array
  1076. * are replaced with a configurable test double. The behavior
  1077. * of the other methods is not changed.
  1078. * Providing null means that no methods will be replaced.
  1079. * @param array $arguments Parameters to pass to the original class' constructor.
  1080. * @param string $mockClassName Class name for the generated test double class.
  1081. * @param boolean $callOriginalConstructor Can be used to disable the call to the original class' constructor.
  1082. * @param boolean $callOriginalClone Can be used to disable the call to the original class' clone constructor.
  1083. * @param boolean $callAutoload Can be used to disable __autoload() during the generation of the test double class.
  1084. * @param boolean $cloneArguments
  1085. * @param boolean $callOriginalMethods
  1086. * @return PHPUnit_Framework_MockObject_MockObject
  1087. * @throws PHPUnit_Framework_Exception
  1088. * @since Method available since Release 3.0.0
  1089. */
  1090. public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false, $callOriginalMethods = false)
  1091. {
  1092. $mockObject = $this->getMockObjectGenerator()->getMock(
  1093. $originalClassName,
  1094. $methods,
  1095. $arguments,
  1096. $mockClassName,
  1097. $callOriginalConstructor,
  1098. $callOriginalClone,
  1099. $callAutoload,
  1100. $cloneArguments,
  1101. $callOriginalMethods
  1102. );
  1103. $this->mockObjects[] = $mockObject;
  1104. return $mockObject;
  1105. }
  1106. /**
  1107. * Returns a builder object to create mock objects using a fluent interface.
  1108. *
  1109. * @param string $className
  1110. * @return PHPUnit_Framework_MockObject_MockBuilder
  1111. * @since Method available since Release 3.5.0
  1112. */
  1113. public function getMockBuilder($className)
  1114. {
  1115. return new PHPUnit_Framework_MockObject_MockBuilder($this, $className);
  1116. }
  1117. /**
  1118. * Mocks the specified class and returns the name of the mocked class.
  1119. *
  1120. * @param string $originalClassName
  1121. * @param array $methods
  1122. * @param array $arguments
  1123. * @param string $mockClassName
  1124. * @param boolean $callOriginalConstructor
  1125. * @param boolean $callOriginalClone
  1126. * @param boolean $callAutoload
  1127. * @param boolean $cloneArguments
  1128. * @return string
  1129. * @throws PHPUnit_Framework_Exception
  1130. * @since Method available since Release 3.5.0
  1131. */
  1132. protected function getMockClass($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = false, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false)
  1133. {
  1134. $mock = $this->getMock(
  1135. $originalClassName,
  1136. $methods,
  1137. $arguments,
  1138. $mockClassName,
  1139. $callOriginalConstructor,
  1140. $callOriginalClone,
  1141. $callAutoload,
  1142. $cloneArguments
  1143. );
  1144. return get_class($mock);
  1145. }
  1146. /**
  1147. * Returns a mock object for the specified abstract class with all abstract
  1148. * methods of the class mocked. Concrete methods are not mocked by default.
  1149. * To mock concrete methods, use the 7th parameter ($mockedMethods).
  1150. *
  1151. * @param string $originalClassName
  1152. * @param array $arguments
  1153. * @param string $mockClassName
  1154. * @param boolean $callOriginalConstructor
  1155. * @param boolean $callOriginalClone
  1156. * @param boolean $callAutoload
  1157. * @param array $mockedMethods
  1158. * @param boolean $cloneArguments
  1159. * @return PHPUnit_Framework_MockObject_MockObject
  1160. * @since Method available since Release 3.4.0
  1161. * @throws PHPUnit_Framework_Exception
  1162. */
  1163. public function getMockForAbstractClass($originalClassName, array $arguments = array(), $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $mockedMethods = array(), $cloneArguments = false)
  1164. {
  1165. $mockObject = $this->getMockObjectGenerator()->getMockForAbstractClass(
  1166. $originalClassName,
  1167. $arguments,
  1168. $mockClassName,
  1169. $callOriginalConstructor,
  1170. $callOriginalClone,
  1171. $callAutoload,
  1172. $mockedMethods,
  1173. $cloneArguments
  1174. );
  1175. $this->mockObjects[] = $mockObject;
  1176. return $mockObject;
  1177. }
  1178. /**
  1179. * Returns a mock object based on the given WSDL file.
  1180. *
  1181. * @param string $wsdlFile
  1182. * @param string $originalClassName
  1183. * @param string $mockClassName
  1184. * @param array $methods
  1185. * @param boolean $callOriginalConstructor
  1186. * @param array $options An array of options passed to SOAPClient::_construct
  1187. * @return PHPUnit_Framework_MockObject_MockObject
  1188. * @since Method available since Release 3.4.0
  1189. */
  1190. protected function getMockFromWsdl($wsdlFile, $originalClassName = '', $mockClassName = '', array $methods = array(), $callOriginalConstructor = true, array $options = array())
  1191. {
  1192. if ($originalClassName === '') {
  1193. $originalClassName = str_replace('.wsdl', '', basename($wsdlFile));
  1194. }
  1195. if (!class_exists($originalClassName)) {
  1196. eval(
  1197. $this->getMockObjectGenerator()->generateClassFromWsdl(
  1198. $wsdlFile,
  1199. $originalClassName,
  1200. $methods,
  1201. $options
  1202. )
  1203. );
  1204. }
  1205. return $this->getMock(
  1206. $originalClassName,
  1207. $methods,
  1208. array('', $options),
  1209. $mockClassName,
  1210. $callOriginalConstructor,
  1211. false,
  1212. false
  1213. );
  1214. }
  1215. /**
  1216. * Returns a mock object for the specified trait with all abstract methods
  1217. * of the trait mocked. Concrete methods to mock can be specified with the
  1218. * `$mockedMethods` parameter.
  1219. *
  1220. * @param string $traitName
  1221. * @param array $arguments
  1222. * @param string $mockClassName
  1223. * @param boolean $callOriginalConstructor
  1224. * @param boolean $callOriginalClone
  1225. * @param boolean $callAutoload
  1226. * @param array $mockedMethods
  1227. * @param boolean $cloneArguments
  1228. * @return PHPUnit_Framework_MockObject_MockObject
  1229. * @since Method available since Release 4.0.0
  1230. * @throws PHPUnit_Framework_Exception
  1231. */
  1232. public function getMockForTrait($traitName, array $arguments = array(), $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $mockedMethods = array(), $cloneArguments = false)
  1233. {
  1234. $mockObject = $this->getMockObjectGenerator()->getMockForTrait(
  1235. $traitName,
  1236. $arguments,
  1237. $mockClassName,
  1238. $callOriginalConstructor,
  1239. $callOriginalClone,
  1240. $callAutoload,
  1241. $mockedMethods,
  1242. $cloneArguments
  1243. );
  1244. $this->mockObjects[] = $mockObject;
  1245. return $mockObject;
  1246. }
  1247. /**
  1248. * Returns an object for the specified trait.
  1249. *
  1250. * @param string $traitName
  1251. * @param array $arguments
  1252. * @param string $traitClassName
  1253. * @param boolean $callOriginalConstructor
  1254. * @param boolean $callOriginalClone
  1255. * @param boolean $callAutoload
  1256. * @param boolean $cloneArguments
  1257. * @return object
  1258. * @since Method available since Release 3.6.0
  1259. * @throws PHPUnit_Framework_Exception
  1260. */
  1261. protected function getObjectForTrait($traitName, array $arguments = array(), $traitClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false)
  1262. {
  1263. return $this->getMockObjectGenerator()->getObjectForTrait(
  1264. $traitName,
  1265. $arguments,
  1266. $traitClassName,
  1267. $callOriginalConstructor,
  1268. $callOriginalClone,
  1269. $callAutoload,
  1270. $cloneArguments
  1271. );
  1272. }
  1273. /**
  1274. * Adds a value to the assertion counter.
  1275. *
  1276. * @param integer $count
  1277. * @since Method available since Release 3.3.3
  1278. */
  1279. public function addToAssertionCount($count)
  1280. {
  1281. $this->numAssertions += $count;
  1282. }
  1283. /**
  1284. * Returns the number of assertions performed by this test.
  1285. *
  1286. * @return integer
  1287. * @since Method available since Release 3.3.0
  1288. */
  1289. public function getNumAssertions()
  1290. {
  1291. return $this->numAssertions;
  1292. }
  1293. /**
  1294. * Returns a matcher that matches when the method it is evaluated for
  1295. * is executed zero or more times.
  1296. *
  1297. * @return PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
  1298. * @since Method available since Release 3.0.0
  1299. */
  1300. public static function any()
  1301. {
  1302. return new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
  1303. }
  1304. /**
  1305. * Returns a matcher that matches when the method it is evaluated for
  1306. * is never executed.
  1307. *
  1308. * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
  1309. * @since Method available since Release 3.0.0
  1310. */
  1311. public static function never()
  1312. {
  1313. return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(0);
  1314. }
  1315. /**
  1316. * Returns a matcher that matches when the method it is evaluated for
  1317. * is executed at least N times.
  1318. *
  1319. * @param integer $requiredInvocations
  1320. * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount
  1321. * @since Method available since Release 4.2.0
  1322. */
  1323. public static function atLeast($requiredInvocations)
  1324. {
  1325. return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount(
  1326. $requiredInvocations
  1327. );
  1328. }
  1329. /**
  1330. * Returns a matcher that matches when the method it is evaluated for
  1331. * is executed at least once.
  1332. *
  1333. * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce
  1334. * @since Method available since Release 3.0.0
  1335. */
  1336. public static function atLeastOnce()
  1337. {
  1338. return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce;
  1339. }
  1340. /**
  1341. * Returns a matcher that matches when the method it is evaluated for
  1342. * is executed exactly once.
  1343. *
  1344. * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
  1345. * @since Method available since Release 3.0.0
  1346. */
  1347. public static function once()
  1348. {
  1349. return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1);
  1350. }
  1351. /**
  1352. * Returns a matcher that matches when the method it is evaluated for
  1353. * is executed exactly $count times.
  1354. *
  1355. * @param integer $count
  1356. * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
  1357. * @since Method available since Release 3.0.0
  1358. */
  1359. public static function exactly($count)
  1360. {
  1361. return new PHPUnit_Framework_MockObject_Matcher_InvokedCount($count);
  1362. }
  1363. /**
  1364. * Returns a matcher that matches when the method it is evaluated for
  1365. * is executed at most N times.
  1366. *
  1367. * @param integer $allowedInvocations
  1368. * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount
  1369. * @since Method available since Release 4.2.0
  1370. */
  1371. public static function atMost($allowedInvocations)
  1372. {
  1373. return new PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount(
  1374. $allowedInvocations
  1375. );
  1376. }
  1377. /**
  1378. * Returns a matcher that matches when the method it is evaluated for
  1379. * is invoked at the given $index.
  1380. *
  1381. * @param integer $index
  1382. * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex
  1383. * @since Method available since Release 3.0.0
  1384. */
  1385. public static function at($index)
  1386. {
  1387. return new PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex($index);
  1388. }
  1389. /**
  1390. *
  1391. *
  1392. * @param mixed $value
  1393. * @return PHPUnit_Framework_MockObject_Stub_Return
  1394. * @since Method available since Release 3.0.0
  1395. */
  1396. public static function returnValue($value)
  1397. {
  1398. return new PHPUnit_Framework_MockObject_Stub_Return($value);
  1399. }
  1400. /**
  1401. *
  1402. *
  1403. * @param array $valueMap
  1404. * @return PHPUnit_Framework_MockObject_Stub_ReturnValueMap
  1405. * @since Method available since Release 3.6.0
  1406. */
  1407. public static function returnValueMap(array $valueMap)
  1408. {
  1409. return new PHPU

Large files files are truncated, but you can click here to view the full file