Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * PHPUnit
4
 *
5
 * Copyright (c) 2002-2010, Sebastian Bergmann <sb@sebastian-bergmann.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
 * @category   Testing
38
 * @package    PHPUnit
39
 * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
40
 * @copyright  2002-2010 Sebastian Bergmann <sb@sebastian-bergmann.de>
41
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
42
 * @link       http://www.phpunit.de/
43
 * @since      File available since Release 2.0.0
44
 */
45
 
46
require_once 'PHPUnit/Framework.php';
47
require_once 'PHPUnit/Framework/MockObject/Generator.php';
48
require_once 'PHPUnit/Framework/MockObject/Matcher/InvokedAtLeastOnce.php';
49
require_once 'PHPUnit/Framework/MockObject/Matcher/InvokedAtIndex.php';
50
require_once 'PHPUnit/Framework/MockObject/Matcher/InvokedCount.php';
51
require_once 'PHPUnit/Framework/MockObject/Stub.php';
52
require_once 'PHPUnit/Runner/BaseTestRunner.php';
53
require_once 'PHPUnit/Util/GlobalState.php';
54
require_once 'PHPUnit/Util/InvalidArgumentHelper.php';
55
require_once 'PHPUnit/Util/PHP.php';
56
require_once 'PHPUnit/Util/Template.php';
57
 
58
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
59
 
60
/**
61
 * A TestCase defines the fixture to run multiple tests.
62
 *
63
 * To define a TestCase
64
 *
65
 *   1) Implement a subclass of PHPUnit_Framework_TestCase.
66
 *   2) Define instance variables that store the state of the fixture.
67
 *   3) Initialize the fixture state by overriding setUp().
68
 *   4) Clean-up after a test by overriding tearDown().
69
 *
70
 * Each test runs in its own fixture so there can be no side effects
71
 * among test runs.
72
 *
73
 * Here is an example:
74
 *
75
 * <code>
76
 * <?php
77
 * require_once 'PHPUnit/Framework/TestCase.php';
78
 *
79
 * class MathTest extends PHPUnit_Framework_TestCase
80
 * {
81
 *     public $value1;
82
 *     public $value2;
83
 *
84
 *     protected function setUp()
85
 *     {
86
 *         $this->value1 = 2;
87
 *         $this->value2 = 3;
88
 *     }
89
 * }
90
 * ?>
91
 * </code>
92
 *
93
 * For each test implement a method which interacts with the fixture.
94
 * Verify the expected results with assertions specified by calling
95
 * assert with a boolean.
96
 *
97
 * <code>
98
 * <?php
99
 * public function testPass()
100
 * {
101
 *     $this->assertTrue($this->value1 + $this->value2 == 5);
102
 * }
103
 * ?>
104
 * </code>
105
 *
106
 * @category   Testing
107
 * @package    PHPUnit
108
 * @author     Sebastian Bergmann <sb@sebastian-bergmann.de>
109
 * @copyright  2002-2010 Sebastian Bergmann <sb@sebastian-bergmann.de>
110
 * @license    http://www.opensource.org/licenses/bsd-license.php  BSD License
111
 * @version    Release: 3.4.15
112
 * @link       http://www.phpunit.de/
113
 * @since      Class available since Release 2.0.0
114
 */
115
abstract class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing
116
{
117
    /**
118
     * Enable or disable the backup and restoration of the $GLOBALS array.
119
     * Overwrite this attribute in a child class of TestCase.
120
     * Setting this attribute in setUp() has no effect!
121
     *
122
     * @var    boolean
123
     */
124
    protected $backupGlobals = NULL;
125
 
126
    /**
127
     * @var    array
128
     */
129
    protected $backupGlobalsBlacklist = array();
130
 
131
    /**
132
     * Enable or disable the backup and restoration of static attributes.
133
     * Overwrite this attribute in a child class of TestCase.
134
     * Setting this attribute in setUp() has no effect!
135
     *
136
     * @var    boolean
137
     */
138
    protected $backupStaticAttributes = NULL;
139
 
140
    /**
141
     * @var    array
142
     */
143
    protected $backupStaticAttributesBlacklist = array();
144
 
145
    /**
146
     * Whether or not this test is to be run in a separate PHP process.
147
     *
148
     * @var    boolean
149
     */
150
    protected $runTestInSeparateProcess = NULL;
151
 
152
    /**
153
     * Whether or not this test should preserve the global state when running in a separate PHP process.
154
     *
155
     * @var    boolean
156
     */
157
    protected $preserveGlobalState = TRUE;
158
 
159
    /**
160
     * Whether or not this test is running in a separate PHP process.
161
     *
162
     * @var    boolean
163
     */
164
    protected $inIsolation = FALSE;
165
 
166
    /**
167
     * @var    array
168
     */
169
    protected $data = array();
170
 
171
    /**
172
     * @var    string
173
     */
174
    protected $dataName = '';
175
 
176
    /**
177
     * @var    boolean
178
     */
179
    protected $useErrorHandler = NULL;
180
 
181
    /**
182
     * @var    boolean
183
     */
184
    protected $useOutputBuffering = NULL;
185
 
186
    /**
187
     * The name of the expected Exception.
188
     *
189
     * @var    mixed
190
     */
191
    protected $expectedException = NULL;
192
 
193
    /**
194
     * The message of the expected Exception.
195
     *
196
     * @var    string
197
     */
198
    protected $expectedExceptionMessage = '';
199
 
200
    /**
201
     * The code of the expected Exception.
202
     *
203
     * @var    integer
204
     */
205
    protected $expectedExceptionCode;
206
 
207
    /**
208
     * Fixture that is shared between the tests of a test suite.
209
     *
210
     * @var    mixed
211
     */
212
    protected $sharedFixture;
213
 
214
    /**
215
     * The name of the test case.
216
     *
217
     * @var    string
218
     */
219
    protected $name = NULL;
220
 
221
    /**
222
     * @var    array
223
     */
224
    protected $dependencies = array();
225
 
226
    /**
227
     * @var    array
228
     */
229
    protected $dependencyInput = array();
230
 
231
    /**
232
     * @var    string
233
     */
234
    protected $exceptionMessage = NULL;
235
 
236
    /**
237
     * @var    integer
238
     */
239
    protected $exceptionCode = 0;
240
 
241
    /**
242
     * @var    Array
243
     */
244
    protected $iniSettings = array();
245
 
246
    /**
247
     * @var    Array
248
     */
249
    protected $locale = array();
250
 
251
    /**
252
     * @var    Array
253
     */
254
    protected $mockObjects = array();
255
 
256
    /**
257
     * @var    integer
258
     */
259
    protected $status;
260
 
261
    /**
262
     * @var    string
263
     */
264
    protected $statusMessage = '';
265
 
266
    /**
267
     * @var    integer
268
     */
269
    protected $numAssertions = 0;
270
 
271
    /**
272
     * @var PHPUnit_Framework_TestResult
273
     */
274
    protected $result;
275
 
276
    /**
277
     * @var mixed
278
     */
279
    protected $testResult;
280
 
281
    /**
282
     * Constructs a test case with the given name.
283
     *
284
     * @param  string $name
285
     * @param  array  $data
286
     * @param  string $dataName
287
     */
288
    public function __construct($name = NULL, array $data = array(), $dataName = '')
289
    {
290
        if ($name !== NULL) {
291
            $this->setName($name);
292
        }
293
 
294
        $this->data     = $data;
295
        $this->dataName = $dataName;
296
    }
297
 
298
    /**
299
     * Returns a string representation of the test case.
300
     *
301
     * @return string
302
     */
303
    public function toString()
304
    {
305
        $class = new ReflectionClass($this);
306
 
307
        $buffer = sprintf(
308
          '%s::%s',
309
 
310
          $class->name,
311
          $this->getName(FALSE)
312
        );
313
 
314
        return $buffer . $this->getDataSetAsString();
315
    }
316
 
317
    /**
318
     * Counts the number of test cases executed by run(TestResult result).
319
     *
320
     * @return integer
321
     */
322
    public function count()
323
    {
324
        return 1;
325
    }
326
 
327
    /**
328
     * Returns the annotations for this test.
329
     *
330
     * @return array
331
     * @since Method available since Release 3.4.0
332
     */
333
    public function getAnnotations()
334
    {
335
        return PHPUnit_Util_Test::parseTestMethodAnnotations(
336
          get_class($this), $this->name
337
        );
338
    }
339
 
340
    /**
341
     * Gets the name of a TestCase.
342
     *
343
     * @param  boolean $withDataSet
344
     * @return string
345
     */
346
    public function getName($withDataSet = TRUE)
347
    {
348
        if ($withDataSet) {
349
            return $this->name . $this->getDataSetAsString(FALSE);
350
        } else {
351
            return $this->name;
352
        }
353
    }
354
 
355
    /**
356
     * @return string
357
     * @since  Method available since Release 3.2.0
358
     */
359
    public function getExpectedException()
360
    {
361
        return $this->expectedException;
362
    }
363
 
364
    /**
365
     * @param  mixed   $exceptionName
366
     * @param  string  $exceptionMessage
367
     * @param  integer $exceptionCode
368
     * @since  Method available since Release 3.2.0
369
     */
370
    public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = 0)
371
    {
372
        $this->expectedException        = $exceptionName;
373
        $this->expectedExceptionMessage = $exceptionMessage;
374
        $this->expectedExceptionCode    = $exceptionCode;
375
    }
376
 
377
    /**
378
     * @since  Method available since Release 3.4.0
379
     */
380
    protected function setExpectedExceptionFromAnnotation()
381
    {
382
        try {
383
            $method            = new ReflectionMethod(get_class($this), $this->name);
384
            $methodDocComment  = $method->getDocComment();
385
            $expectedException = PHPUnit_Util_Test::getExpectedException($methodDocComment);
386
 
387
            if ($expectedException !== FALSE) {
388
                $this->setExpectedException(
389
                  $expectedException['class'],
390
                  $expectedException['message'],
391
                  $expectedException['code']
392
                );
393
            }
394
        }
395
 
396
        catch (ReflectionException $e) {
397
        }
398
    }
399
 
400
    /**
401
     * @param boolean $useErrorHandler
402
     * @since Method available since Release 3.4.0
403
     */
404
    public function setUseErrorHandler($useErrorHandler)
405
    {
406
        $this->useErrorHandler = $useErrorHandler;
407
    }
408
 
409
    /**
410
     * @since Method available since Release 3.4.0
411
     */
412
    protected function setUseErrorHandlerFromAnnotation()
413
    {
414
        try {
415
            $useErrorHandler = PHPUnit_Util_Test::getErrorHandlerSettings(
416
              get_class($this), $this->name
417
            );
418
 
419
            if ($useErrorHandler !== NULL) {
420
                $this->setUseErrorHandler($useErrorHandler);
421
            }
422
        }
423
 
424
        catch (ReflectionException $e) {
425
        }
426
    }
427
 
428
    /**
429
     * @param boolean $useOutputBuffering
430
     * @since Method available since Release 3.4.0
431
     */
432
    public function setUseOutputBuffering($useOutputBuffering)
433
    {
434
        $this->useOutputBuffering = $useOutputBuffering;
435
    }
436
 
437
    /**
438
     * @since Method available since Release 3.4.0
439
     */
440
    protected function setUseOutputBufferingFromAnnotation()
441
    {
442
        try {
443
            $useOutputBuffering = PHPUnit_Util_Test::getOutputBufferingSettings(
444
              get_class($this), $this->name
445
            );
446
 
447
            if ($useOutputBuffering !== NULL) {
448
                $this->setUseOutputBuffering($useOutputBuffering);
449
            }
450
        }
451
 
452
        catch (ReflectionException $e) {
453
        }
454
    }
455
 
456
    /**
457
     * Returns the status of this test.
458
     *
459
     * @return integer
460
     * @since  Method available since Release 3.1.0
461
     */
462
    public function getStatus()
463
    {
464
        return $this->status;
465
    }
466
 
467
    /**
468
     * Returns the status message of this test.
469
     *
470
     * @return string
471
     * @since  Method available since Release 3.3.0
472
     */
473
    public function getStatusMessage()
474
    {
475
        return $this->statusMessage;
476
    }
477
 
478
    /**
479
     * Returns whether or not this test has failed.
480
     *
481
     * @return boolean
482
     * @since  Method available since Release 3.0.0
483
     */
484
    public function hasFailed()
485
    {
486
        $status = $this->getStatus();
487
 
488
        return $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE ||
489
               $status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR;
490
    }
491
 
492
    /**
493
     * Runs the test case and collects the results in a TestResult object.
494
     * If no TestResult object is passed a new one will be created.
495
     *
496
     * @param  PHPUnit_Framework_TestResult $result
497
     * @return PHPUnit_Framework_TestResult
498
     * @throws InvalidArgumentException
499
     */
500
    public function run(PHPUnit_Framework_TestResult $result = NULL)
501
    {
502
        if ($result === NULL) {
503
            $result = $this->createResult();
504
        }
505
 
506
        $this->setExpectedExceptionFromAnnotation();
507
        $this->setUseErrorHandlerFromAnnotation();
508
        $this->setUseOutputBufferingFromAnnotation();
509
 
510
        if ($this->useErrorHandler !== NULL) {
511
            $oldErrorHandlerSetting = $result->getConvertErrorsToExceptions();
512
            $result->convertErrorsToExceptions($this->useErrorHandler);
513
        }
514
 
515
        $this->result = $result;
516
 
517
        if (!empty($this->dependencies) && !$this->inIsolation) {
518
            $className  = get_class($this);
519
            $passed     = $this->result->passed();
520
            $passedKeys = array_keys($passed);
521
            $numKeys    = count($passedKeys);
522
 
523
            for ($i = 0; $i < $numKeys; $i++) {
524
                $pos = strpos($passedKeys[$i], ' with data set');
525
 
526
                if ($pos !== FALSE) {
527
                    $passedKeys[$i] = substr($passedKeys[$i], 0, $pos);
528
                }
529
            }
530
 
531
            $passedKeys = array_flip(array_unique($passedKeys));
532
 
533
            foreach ($this->dependencies as $dependency) {
534
                if (strpos($dependency, '::') === FALSE) {
535
                    $dependency = $className . '::' . $dependency;
536
                }
537
 
538
                if (!isset($passedKeys[$dependency])) {
539
                    $result->addError(
540
                      $this,
541
                      new PHPUnit_Framework_SkippedTestError(
542
                        sprintf(
543
                          'This test depends on "%s" to pass.', $dependency
544
                        )
545
                      ),
546
 
547
                    );
548
 
549
                    return;
550
                } else {
551
                    if (isset($passed[$dependency])) {
552
                        $this->dependencyInput[] = $passed[$dependency];
553
                    } else {
554
                        $this->dependencyInput[] = NULL;
555
                    }
556
                }
557
            }
558
        }
559
 
560
        if ($this->runTestInSeparateProcess === TRUE &&
561
            $this->inIsolation !== TRUE &&
562
            !$this instanceof PHPUnit_Extensions_SeleniumTestCase &&
563
            !$this instanceof PHPUnit_Extensions_PhptTestCase) {
564
            $class                          = new ReflectionClass($this);
565
            $collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation();
566
 
567
            $template = new PHPUnit_Util_Template(
568
              sprintf(
569
                '%s%sProcess%sTestCaseMethod.tpl',
570
 
571
                dirname(__FILE__),
572
                DIRECTORY_SEPARATOR,
573
                DIRECTORY_SEPARATOR,
574
                DIRECTORY_SEPARATOR
575
              )
576
            );
577
 
578
            $template->setVar(
579
              array(
580
                'filename'                       => $class->getFileName(),
581
                'className'                      => $class->getName(),
582
                'methodName'                     => $this->name,
583
                'data'                           => addcslashes(serialize($this->data), "'"),
584
                'dependencyInput'                => addcslashes(serialize($this->dependencyInput), "'"),
585
                'dataName'                       => $this->dataName,
586
                'collectCodeCoverageInformation' => $collectCodeCoverageInformation ? 'TRUE' : 'FALSE',
587
                'included_files'                 => $this->preserveGlobalState ? PHPUnit_Util_GlobalState::getIncludedFilesAsString() : '',
588
                'constants'                      => $this->preserveGlobalState ? PHPUnit_Util_GlobalState::getConstantsAsString() : '',
589
                'globals'                        => $this->preserveGlobalState ? PHPUnit_Util_GlobalState::getGlobalsAsString() : '',
590
                'include_path'                   => addslashes(get_include_path())
591
              )
592
            );
593
 
594
            $this->prepareTemplate($template);
595
            $job = $template->render();
596
            $result->startTest($this);
597
 
598
            $jobResult = PHPUnit_Util_PHP::runJob($job);
599
 
600
            if (!empty($jobResult['stderr'])) {
601
                $time = 0;
602
                $result->addError(
603
                  $this,
604
                  new RuntimeException(trim($jobResult['stderr'])), $time
605
                );
606
            } else {
607
                $childResult = @unserialize($jobResult['stdout']);
608
 
609
                if ($childResult !== FALSE) {
610
                    if (!empty($childResult['output'])) {
611
                        print $childResult['output'];
612
                    }
613
 
614
                    $this->testResult    = $childResult['testResult'];
615
                    $this->numAssertions = $childResult['numAssertions'];
616
                    $childResult         = $childResult['result'];
617
 
618
                    if ($collectCodeCoverageInformation) {
619
                        $codeCoverageInformation = $childResult->getRawCodeCoverageInformation();
620
 
621
                        $result->appendCodeCoverageInformation(
622
                          $this, $codeCoverageInformation[0]['data']
623
                        );
624
                    }
625
 
626
                    $time           = $childResult->time();
627
                    $notImplemented = $childResult->notImplemented();
628
                    $skipped        = $childResult->skipped();
629
                    $errors         = $childResult->errors();
630
                    $failures       = $childResult->failures();
631
 
632
                    if (!empty($notImplemented)) {
633
                        $result->addError(
634
                          $this, $notImplemented[0]->thrownException(), $time
635
                        );
636
                    }
637
 
638
                    else if (!empty($skipped)) {
639
                        $result->addError(
640
                          $this, $skipped[0]->thrownException(), $time
641
                        );
642
                    }
643
 
644
                    else if (!empty($errors)) {
645
                        $result->addError(
646
                          $this, $errors[0]->thrownException(), $time
647
                        );
648
                    }
649
 
650
                    else if (!empty($failures)) {
651
                        $result->addFailure(
652
                          $this, $failures[0]->thrownException(), $time
653
                        );
654
                    }
655
                } else {
656
                    $time = 0;
657
                    $result->addError(
658
                      $this,
659
                      new RuntimeException(trim($jobResult['stdout'])), $time
660
                    );
661
                }
662
            }
663
 
664
            $result->endTest($this, $time);
665
        } else {
666
            $result->run($this);
667
        }
668
 
669
        if ($this->useErrorHandler !== NULL) {
670
            $result->convertErrorsToExceptions($oldErrorHandlerSetting);
671
        }
672
 
673
        $this->result = NULL;
674
 
675
        return $result;
676
    }
677
 
678
    /**
679
     * Runs the bare test sequence.
680
     */
681
    public function runBare()
682
    {
683
        $this->numAssertions = 0;
684
 
685
        // Backup the $GLOBALS array and static attributes.
686
        if ($this->runTestInSeparateProcess !== TRUE &&
687
            $this->inIsolation !== TRUE) {
688
            if ($this->backupGlobals === NULL ||
689
                $this->backupGlobals === TRUE) {
690
                PHPUnit_Util_GlobalState::backupGlobals(
691
                  $this->backupGlobalsBlacklist
692
                );
693
            }
694
 
695
            if (version_compare(PHP_VERSION, '5.3', '>') &&
696
                $this->backupStaticAttributes === TRUE) {
697
                PHPUnit_Util_GlobalState::backupStaticAttributes(
698
                  $this->backupStaticAttributesBlacklist
699
                );
700
            }
701
        }
702
 
703
        // Start output buffering.
704
        if ($this->useOutputBuffering === TRUE) {
705
            ob_start();
706
        }
707
 
708
        // Clean up stat cache.
709
        clearstatcache();
710
 
711
        // Run the test.
712
        try {
713
            // Set up the fixture.
714
            if ($this->inIsolation) {
715
                $this->setUpBeforeClass();
716
            }
717
 
718
            $this->setUp();
719
 
720
            // Assert pre-conditions.
721
            $this->assertPreConditions();
722
 
723
            $this->testResult = $this->runTest();
724
 
725
            // Assert post-conditions.
726
            $this->assertPostConditions();
727
 
728
            // Verify Mock Object conditions.
729
            foreach ($this->mockObjects as $mockObject) {
730
                $this->numAssertions++;
731
                $mockObject->__phpunit_verify();
732
                $mockObject->__phpunit_cleanup();
733
            }
734
 
735
            $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
736
        }
737
 
738
        catch (PHPUnit_Framework_IncompleteTest $e) {
739
            $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE;
740
            $this->statusMessage = $e->getMessage();
741
        }
742
 
743
        catch (PHPUnit_Framework_SkippedTest $e) {
744
            $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED;
745
            $this->statusMessage = $e->getMessage();
746
        }
747
 
748
        catch (PHPUnit_Framework_AssertionFailedError $e) {
749
            $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE;
750
            $this->statusMessage = $e->getMessage();
751
        }
752
 
753
        catch (Exception $e) {
754
            $this->status = PHPUnit_Runner_BaseTestRunner::STATUS_ERROR;
755
            $this->statusMessage = $e->getMessage();
756
        }
757
 
758
        $this->mockObjects = array();
759
 
760
        // Tear down the fixture. An exception raised in tearDown() will be
761
        // caught and passed on when no exception was raised before.
762
        try {
763
            $this->tearDown();
764
 
765
            if ($this->inIsolation) {
766
                $this->tearDownAfterClass();
767
            }
768
        }
769
 
770
        catch (Exception $_e) {
771
            if (!isset($e)) {
772
                $e = $_e;
773
            }
774
        }
775
 
776
        // Stop output buffering.
777
        if ($this->useOutputBuffering === TRUE) {
778
            ob_end_clean();
779
        }
780
 
781
        // Clean up stat cache.
782
        clearstatcache();
783
 
784
        // Restore the $GLOBALS array and static attributes.
785
        if ($this->runTestInSeparateProcess !== TRUE &&
786
            $this->inIsolation !== TRUE) {
787
            if ($this->backupGlobals === NULL ||
788
                $this->backupGlobals === TRUE) {
789
                PHPUnit_Util_GlobalState::restoreGlobals(
790
                   $this->backupGlobalsBlacklist
791
                );
792
            }
793
 
794
            if (version_compare(PHP_VERSION, '5.3', '>') &&
795
                $this->backupStaticAttributes === TRUE) {
796
                PHPUnit_Util_GlobalState::restoreStaticAttributes();
797
            }
798
        }
799
 
800
        // Clean up INI settings.
801
        foreach ($this->iniSettings as $varName => $oldValue) {
802
            ini_set($varName, $oldValue);
803
        }
804
 
805
        $this->iniSettings = array();
806
 
807
        // Clean up locale settings.
808
        foreach ($this->locale as $category => $locale) {
809
            setlocale($category, $locale);
810
        }
811
 
812
        // Workaround for missing "finally".
813
        if (isset($e)) {
814
            $this->onNotSuccessfulTest($e);
815
        }
816
    }
817
 
818
    /**
819
     * Override to run the test and assert its state.
820
     *
821
     * @return mixed
822
     * @throws RuntimeException
823
     */
824
    protected function runTest()
825
    {
826
        if ($this->name === NULL) {
827
            throw new PHPUnit_Framework_Exception(
828
              'PHPUnit_Framework_TestCase::$name must not be NULL.'
829
            );
830
        }
831
 
832
        try {
833
            $class  = new ReflectionClass($this);
834
            $method = $class->getMethod($this->name);
835
        }
836
 
837
        catch (ReflectionException $e) {
838
            $this->fail($e->getMessage());
839
        }
840
 
841
        try {
842
            $testResult = $method->invokeArgs(
843
              $this, array_merge($this->data, $this->dependencyInput)
844
            );
845
        }
846
 
847
        catch (Exception $e) {
848
            if (!$e instanceof PHPUnit_Framework_IncompleteTest &&
849
                !$e instanceof PHPUnit_Framework_SkippedTest &&
850
                is_string($this->expectedException) &&
851
                $e instanceof $this->expectedException) {
852
                if (is_string($this->expectedExceptionMessage) &&
853
                    !empty($this->expectedExceptionMessage)) {
854
                    $this->assertContains(
855
                      $this->expectedExceptionMessage,
856
                      $e->getMessage()
857
                    );
858
                }
859
 
860
                if (is_int($this->expectedExceptionCode) &&
861
                    $this->expectedExceptionCode !== 0) {
862
                    $this->assertEquals(
863
                      $this->expectedExceptionCode, $e->getCode()
864
                    );
865
                }
866
 
867
                $this->numAssertions++;
868
 
869
                return;
870
            } else {
871
                throw $e;
872
            }
873
        }
874
 
875
        if ($this->expectedException !== NULL) {
876
            $this->numAssertions++;
877
            $this->fail('Expected exception ' . $this->expectedException);
878
        }
879
 
880
        return $testResult;
881
    }
882
 
883
    /**
884
     * Sets the name of a TestCase.
885
     *
886
     * @param  string
887
     */
888
    public function setName($name)
889
    {
890
        $this->name = $name;
891
    }
892
 
893
    /**
894
     * Sets the dependencies of a TestCase.
895
     *
896
     * @param  array $dependencies
897
     * @since  Method available since Release 3.4.0
898
     */
899
    public function setDependencies(array $dependencies)
900
    {
901
        $this->dependencies = $dependencies;
902
    }
903
 
904
    /**
905
     * Sets
906
     *
907
     * @param  array $dependencyInput
908
     * @since  Method available since Release 3.4.0
909
     */
910
    public function setDependencyInput(array $dependencyInput)
911
    {
912
        $this->dependencyInput = $dependencyInput;
913
    }
914
 
915
    /**
916
     * Calling this method in setUp() has no effect!
917
     *
918
     * @param  boolean $backupGlobals
919
     * @since  Method available since Release 3.3.0
920
     */
921
    public function setBackupGlobals($backupGlobals)
922
    {
923
        if (is_null($this->backupGlobals) && is_bool($backupGlobals)) {
924
            $this->backupGlobals = $backupGlobals;
925
        }
926
    }
927
 
928
    /**
929
     * Calling this method in setUp() has no effect!
930
     *
931
     * @param  boolean $backupStaticAttributes
932
     * @since  Method available since Release 3.4.0
933
     */
934
    public function setBackupStaticAttributes($backupStaticAttributes)
935
    {
936
        if (is_null($this->backupStaticAttributes) &&
937
            is_bool($backupStaticAttributes)) {
938
            $this->backupStaticAttributes = $backupStaticAttributes;
939
        }
940
    }
941
 
942
    /**
943
     * @param  boolean $runTestInSeparateProcess
944
     * @throws InvalidArgumentException
945
     * @since  Method available since Release 3.4.0
946
     */
947
    public function setRunTestInSeparateProcess($runTestInSeparateProcess)
948
    {
949
        if (is_bool($runTestInSeparateProcess)) {
950
            if ($this->runTestInSeparateProcess === NULL) {
951
                $this->runTestInSeparateProcess = $runTestInSeparateProcess;
952
            }
953
        } else {
954
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean');
955
        }
956
    }
957
 
958
    /**
959
     * @param  boolean $preserveGlobalState
960
     * @throws InvalidArgumentException
961
     * @since  Method available since Release 3.4.0
962
     */
963
    public function setPreserveGlobalState($preserveGlobalState)
964
    {
965
        if (is_bool($preserveGlobalState)) {
966
            $this->preserveGlobalState = $preserveGlobalState;
967
        } else {
968
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean');
969
        }
970
    }
971
 
972
    /**
973
     * @param  boolean $inIsolation
974
     * @throws InvalidArgumentException
975
     * @since  Method available since Release 3.4.0
976
     */
977
    public function setInIsolation($inIsolation)
978
    {
979
        if (is_bool($inIsolation)) {
980
            $this->inIsolation = $inIsolation;
981
        } else {
982
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'boolean');
983
        }
984
    }
985
 
986
    /**
987
     * Sets the shared fixture.
988
     *
989
     * @param  mixed $sharedFixture
990
     * @since  Method available since Release 3.1.0
991
     */
992
    public function setSharedFixture($sharedFixture)
993
    {
994
        $this->sharedFixture = $sharedFixture;
995
    }
996
 
997
    /**
998
     * @return mixed
999
     * @since  Method available since Release 3.4.0
1000
     */
1001
    public function getResult()
1002
    {
1003
        return $this->testResult;
1004
    }
1005
 
1006
    /**
1007
     * @param  mixed $result
1008
     * @since  Method available since Release 3.4.0
1009
     */
1010
    public function setResult($result)
1011
    {
1012
        $this->testResult = $result;
1013
    }
1014
 
1015
    /**
1016
     * This method is a wrapper for the ini_set() function that automatically
1017
     * resets the modified php.ini setting to its original value after the
1018
     * test is run.
1019
     *
1020
     * @param  string  $varName
1021
     * @param  string  $newValue
1022
     * @throws InvalidArgumentException
1023
     * @throws RuntimeException
1024
     * @since  Method available since Release 3.0.0
1025
     */
1026
    protected function iniSet($varName, $newValue)
1027
    {
1028
        if (!is_string($varName)) {
1029
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1030
        }
1031
 
1032
        $currentValue = ini_set($varName, $newValue);
1033
 
1034
        if ($currentValue !== FALSE) {
1035
            $this->iniSettings[$varName] = $currentValue;
1036
        } else {
1037
            throw new PHPUnit_Framework_Exception(
1038
              sprintf(
1039
                'INI setting "%s" could not be set to "%s".',
1040
                $varName,
1041
                $newValue
1042
              )
1043
            );
1044
        }
1045
    }
1046
 
1047
    /**
1048
     * This method is a wrapper for the setlocale() function that automatically
1049
     * resets the locale to its original value after the test is run.
1050
     *
1051
     * @param  integer $category
1052
     * @param  string  $locale
1053
     * @throws InvalidArgumentException
1054
     * @throws RuntimeException
1055
     * @since  Method available since Release 3.1.0
1056
     */
1057
    protected function setLocale()
1058
    {
1059
        $args = func_get_args();
1060
 
1061
        if (count($args) < 2) {
1062
            throw new InvalidArgumentException;
1063
        }
1064
 
1065
        $category = $args[0];
1066
        $locale   = $args[1];
1067
 
1068
        $categories = array(
1069
          LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
1070
        );
1071
 
1072
        if (defined('LC_MESSAGES')) {
1073
            $categories[] = LC_MESSAGES;
1074
        }
1075
 
1076
        if (!in_array($category, $categories)) {
1077
            throw new InvalidArgumentException;
1078
        }
1079
 
1080
        if (!is_array($locale) && !is_string($locale)) {
1081
            throw new InvalidArgumentException;
1082
        }
1083
 
1084
        $this->locale[$category] = setlocale($category, NULL);
1085
 
1086
        $result = call_user_func_array( 'setlocale', $args );
1087
 
1088
        if ($result === FALSE) {
1089
            throw new PHPUnit_Framework_Exception(
1090
              'The locale functionality is not implemented on your platform, ' .
1091
              'the specified locale does not exist or the category name is ' .
1092
              'invalid.'
1093
            );
1094
        }
1095
    }
1096
 
1097
    /**
1098
     * Returns a mock object for the specified class.
1099
     *
1100
     * @param  string  $originalClassName
1101
     * @param  array   $methods
1102
     * @param  array   $arguments
1103
     * @param  string  $mockClassName
1104
     * @param  boolean $callOriginalConstructor
1105
     * @param  boolean $callOriginalClone
1106
     * @param  boolean $callAutoload
1107
     * @return PHPUnit_Framework_MockObject_MockObject
1108
     * @throws InvalidArgumentException
1109
     * @since  Method available since Release 3.0.0
1110
     */
1111
    protected function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE)
1112
    {
1113
        if (!is_string($originalClassName)) {
1114
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1115
        }
1116
 
1117
        if (!is_string($mockClassName)) {
1118
            throw PHPUnit_Util_InvalidArgumentHelper::factory(4, 'string');
1119
        }
1120
 
1121
        if (!is_array($methods) && !is_null($methods)) {
1122
            throw new InvalidArgumentException;
1123
        }
1124
 
1125
        if ($mockClassName != '' && class_exists($mockClassName, FALSE)) {
1126
            throw new PHPUnit_Framework_Exception(
1127
              sprintf(
1128
                'Class "%s" already exists.',
1129
                $mockClassName
1130
              )
1131
            );
1132
        }
1133
 
1134
        $mock = PHPUnit_Framework_MockObject_Generator::generate(
1135
          $originalClassName,
1136
          $methods,
1137
          $mockClassName,
1138
          $callOriginalClone,
1139
          $callAutoload
1140
        );
1141
 
1142
        if (!class_exists($mock['mockClassName'], FALSE)) {
1143
            eval($mock['code']);
1144
        }
1145
 
1146
        if ($callOriginalConstructor && !interface_exists($originalClassName, $callAutoload)) {
1147
            if (count($arguments) == 0) {
1148
                $mockObject = new $mock['mockClassName'];
1149
            } else {
1150
                $mockClass  = new ReflectionClass($mock['mockClassName']);
1151
                $mockObject = $mockClass->newInstanceArgs($arguments);
1152
            }
1153
        } else {
1154
            // Use a trick to create a new object of a class
1155
            // without invoking its constructor.
1156
            $mockObject = unserialize(
1157
              sprintf(
1158
                'O:%d:"%s":0:{}',
1159
                strlen($mock['mockClassName']), $mock['mockClassName']
1160
              )
1161
            );
1162
        }
1163
 
1164
        $this->mockObjects[] = $mockObject;
1165
 
1166
        return $mockObject;
1167
    }
1168
 
1169
    /**
1170
     * Returns a mock object for the specified abstract class with all abstract
1171
     * methods of the class mocked. Concrete methods are not mocked.
1172
     *
1173
     * @param  string  $originalClassName
1174
     * @param  array   $arguments
1175
     * @param  string  $mockClassName
1176
     * @param  boolean $callOriginalConstructor
1177
     * @param  boolean $callOriginalClone
1178
     * @param  boolean $callAutoload
1179
     * @return PHPUnit_Framework_MockObject_MockObject
1180
     * @since  Method available since Release 3.4.0
1181
     * @throws InvalidArgumentException
1182
     */
1183
    protected function getMockForAbstractClass($originalClassName, array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE)
1184
    {
1185
        if (!is_string($originalClassName)) {
1186
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1187
        }
1188
 
1189
        if (!is_string($mockClassName)) {
1190
            throw PHPUnit_Util_InvalidArgumentHelper::factory(3, 'string');
1191
        }
1192
 
1193
        if (class_exists($originalClassName, $callAutoload)) {
1194
            $methods   = array();
1195
            $reflector = new ReflectionClass($originalClassName);
1196
 
1197
            foreach ($reflector->getMethods() as $method) {
1198
                if ($method->isAbstract()) {
1199
                    $methods[] = $method->getName();
1200
                }
1201
            }
1202
 
1203
            if (empty($methods)) {
1204
                $methods = NULL;
1205
            }
1206
 
1207
            return $this->getMock(
1208
              $originalClassName,
1209
              $methods,
1210
              $arguments,
1211
              $mockClassName,
1212
              $callOriginalConstructor,
1213
              $callOriginalClone,
1214
              $callAutoload
1215
            );
1216
        } else {
1217
            throw new PHPUnit_Framework_Exception(
1218
              sprintf(
1219
                'Class "%s" does not exist.',
1220
                $originalClassName
1221
              )
1222
            );
1223
        }
1224
    }
1225
 
1226
    /**
1227
     * Returns a mock object based on the given WSDL file.
1228
     *
1229
     * @param  string  $wsdlFile
1230
     * @param  string  $originalClassName
1231
     * @param  string  $mockClassName
1232
     * @param  array   $methods
1233
     * @param  boolean $callOriginalConstructor
1234
     * @return PHPUnit_Framework_MockObject_MockObject
1235
     * @since  Method available since Release 3.4.0
1236
     */
1237
    protected function getMockFromWsdl($wsdlFile, $originalClassName = '', $mockClassName = '', array $methods = array(), $callOriginalConstructor = TRUE)
1238
    {
1239
        if ($originalClassName === '') {
1240
            $originalClassName = str_replace(
1241
              '.wsdl', '', basename($wsdlFile)
1242
            );
1243
        }
1244
 
1245
        eval(
1246
          PHPUnit_Framework_MockObject_Generator::generateClassFromWsdl(
1247
            $wsdlFile, $originalClassName, $methods
1248
          )
1249
        );
1250
 
1251
        return $this->getMock(
1252
          $originalClassName,
1253
          $methods,
1254
          array('', array()),
1255
          $mockClassName,
1256
          $callOriginalConstructor,
1257
          FALSE,
1258
          FALSE
1259
        );
1260
    }
1261
 
1262
    /**
1263
     * Adds a value to the assertion counter.
1264
     *
1265
     * @param integer $count
1266
     * @since Method available since Release 3.3.3
1267
     */
1268
    public function addToAssertionCount($count)
1269
    {
1270
        $this->numAssertions += $count;
1271
    }
1272
 
1273
    /**
1274
     * Returns the number of assertions performed by this test.
1275
     *
1276
     * @return integer
1277
     * @since  Method available since Release 3.3.0
1278
     */
1279
    public function getNumAssertions()
1280
    {
1281
        return $this->numAssertions;
1282
    }
1283
 
1284
    /**
1285
     * Returns a matcher that matches when the method it is evaluated for
1286
     * is executed zero or more times.
1287
     *
1288
     * @return PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
1289
     * @since  Method available since Release 3.0.0
1290
     */
1291
    protected function any()
1292
    {
1293
        return new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
1294
    }
1295
 
1296
    /**
1297
     * Returns a matcher that matches when the method it is evaluated for
1298
     * is never executed.
1299
     *
1300
     * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1301
     * @since  Method available since Release 3.0.0
1302
     */
1303
    protected function never()
1304
    {
1305
        return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(0);
1306
    }
1307
 
1308
    /**
1309
     * Returns a matcher that matches when the method it is evaluated for
1310
     * is executed at least once.
1311
     *
1312
     * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce
1313
     * @since  Method available since Release 3.0.0
1314
     */
1315
    protected function atLeastOnce()
1316
    {
1317
        return new PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce;
1318
    }
1319
 
1320
    /**
1321
     * Returns a matcher that matches when the method it is evaluated for
1322
     * is executed exactly once.
1323
     *
1324
     * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1325
     * @since  Method available since Release 3.0.0
1326
     */
1327
    protected function once()
1328
    {
1329
        return new PHPUnit_Framework_MockObject_Matcher_InvokedCount(1);
1330
    }
1331
 
1332
    /**
1333
     * Returns a matcher that matches when the method it is evaluated for
1334
     * is executed exactly $count times.
1335
     *
1336
     * @param  integer $count
1337
     * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
1338
     * @since  Method available since Release 3.0.0
1339
     */
1340
    protected function exactly($count)
1341
    {
1342
        return new PHPUnit_Framework_MockObject_Matcher_InvokedCount($count);
1343
    }
1344
 
1345
    /**
1346
     * Returns a matcher that matches when the method it is evaluated for
1347
     * is invoked at the given $index.
1348
     *
1349
     * @param  integer $index
1350
     * @return PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex
1351
     * @since  Method available since Release 3.0.0
1352
     */
1353
    protected function at($index)
1354
    {
1355
        return new PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex($index);
1356
    }
1357
 
1358
    /**
1359
     *
1360
     *
1361
     * @param  mixed $value
1362
     * @return PHPUnit_Framework_MockObject_Stub_Return
1363
     * @since  Method available since Release 3.0.0
1364
     */
1365
    protected function returnValue($value)
1366
    {
1367
        return new PHPUnit_Framework_MockObject_Stub_Return($value);
1368
    }
1369
 
1370
    /**
1371
     *
1372
     *
1373
     * @param  integer $argumentIndex
1374
     * @return PHPUnit_Framework_MockObject_Stub_ReturnArgument
1375
     * @since  Method available since Release 3.3.0
1376
     */
1377
    protected function returnArgument($argumentIndex)
1378
    {
1379
        return new PHPUnit_Framework_MockObject_Stub_ReturnArgument(
1380
          $argumentIndex
1381
        );
1382
    }
1383
 
1384
    /**
1385
     *
1386
     *
1387
     * @param  mixed $callback
1388
     * @return PHPUnit_Framework_MockObject_Stub_ReturnCallback
1389
     * @since  Method available since Release 3.3.0
1390
     */
1391
    protected function returnCallback($callback)
1392
    {
1393
        return new PHPUnit_Framework_MockObject_Stub_ReturnCallback($callback);
1394
    }
1395
 
1396
    /**
1397
     *
1398
     *
1399
     * @param  Exception $exception
1400
     * @return PHPUnit_Framework_MockObject_Stub_Exception
1401
     * @since  Method available since Release 3.1.0
1402
     */
1403
    protected function throwException(Exception $exception)
1404
    {
1405
        return new PHPUnit_Framework_MockObject_Stub_Exception($exception);
1406
    }
1407
 
1408
    /**
1409
     *
1410
     *
1411
     * @param  mixed $value, ...
1412
     * @return PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls
1413
     * @since  Method available since Release 3.0.0
1414
     */
1415
    protected function onConsecutiveCalls()
1416
    {
1417
        $args = func_get_args();
1418
 
1419
        return new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($args);
1420
    }
1421
 
1422
    /**
1423
     * @param  mixed $data
1424
     * @return string
1425
     * @since  Method available since Release 3.2.1
1426
     */
1427
    protected function dataToString($data)
1428
    {
1429
        $result = array();
1430
 
1431
        foreach ($data as $_data) {
1432
            if (is_array($_data)) {
1433
                $result[] = 'array(' . $this->dataToString($_data) . ')';
1434
            }
1435
 
1436
            else if (is_object($_data)) {
1437
                $object = new ReflectionObject($_data);
1438
 
1439
                if ($object->hasMethod('__toString')) {
1440
                    $result[] = (string)$_data;
1441
                } else {
1442
                    $result[] = get_class($_data);
1443
                }
1444
            }
1445
 
1446
            else if (is_resource($_data)) {
1447
                $result[] = '<resource>';
1448
            }
1449
 
1450
            else {
1451
                $result[] = var_export($_data, TRUE);
1452
            }
1453
        }
1454
 
1455
        return join(', ', $result);
1456
    }
1457
 
1458
    /**
1459
     * Gets the data set description of a TestCase.
1460
     *
1461
     * @param  boolean $includeData
1462
     * @return string
1463
     * @since  Method available since Release 3.3.0
1464
     */
1465
    protected function getDataSetAsString($includeData = TRUE)
1466
    {
1467
        $buffer = '';
1468
 
1469
        if (!empty($this->data)) {
1470
            if (is_int($this->dataName)) {
1471
                $buffer .= sprintf(' with data set #%d', $this->dataName);
1472
            } else {
1473
                $buffer .= sprintf(' with data set "%s"', $this->dataName);
1474
            }
1475
 
1476
            if ($includeData) {
1477
                $buffer .= sprintf(' (%s)', $this->dataToString($this->data));
1478
            }
1479
        }
1480
 
1481
        return $buffer;
1482
    }
1483
 
1484
    /**
1485
     * Creates a default TestResult object.
1486
     *
1487
     * @return PHPUnit_Framework_TestResult
1488
     */
1489
    protected function createResult()
1490
    {
1491
        return new PHPUnit_Framework_TestResult;
1492
    }
1493
 
1494
    /**
1495
     * This method is called before the first test of this test class is run.
1496
     *
1497
     * @since Method available since Release 3.4.0
1498
     */
1499
    public static function setUpBeforeClass()
1500
    {
1501
    }
1502
 
1503
    /**
1504
     * Sets up the fixture, for example, open a network connection.
1505
     * This method is called before a test is executed.
1506
     *
1507
     */
1508
    protected function setUp()
1509
    {
1510
    }
1511
 
1512
    /**
1513
     * Performs assertions shared by all tests of a test case.
1514
     *
1515
     * This method is called before the execution of a test starts
1516
     * and after setUp() is called.
1517
     *
1518
     * @since  Method available since Release 3.2.8
1519
     */
1520
    protected function assertPreConditions()
1521
    {
1522
    }
1523
 
1524
    /**
1525
     * Performs assertions shared by all tests of a test case.
1526
     *
1527
     * This method is called before the execution of a test ends
1528
     * and before tearDown() is called.
1529
     *
1530
     * @since  Method available since Release 3.2.8
1531
     */
1532
    protected function assertPostConditions()
1533
    {
1534
    }
1535
 
1536
    /**
1537
     * Tears down the fixture, for example, close a network connection.
1538
     * This method is called after a test is executed.
1539
     */
1540
    protected function tearDown()
1541
    {
1542
    }
1543
 
1544
    /**
1545
     * This method is called after the last test of this test class is run.
1546
     *
1547
     * @since Method available since Release 3.4.0
1548
     */
1549
    public static function tearDownAfterClass()
1550
    {
1551
    }
1552
 
1553
    /**
1554
     * This method is called when a test method did not execute successfully.
1555
     *
1556
     * @param Exception $e
1557
     * @since Method available since Release 3.4.0
1558
     */
1559
    protected function onNotSuccessfulTest(Exception $e)
1560
    {
1561
        throw $e;
1562
    }
1563
 
1564
    /**
1565
     * Performs custom preparations on the process isolation template.
1566
     *
1567
     * @param PHPUnit_Util_Template $template
1568
     * @since Method available since Release 3.4.0
1569
     */
1570
    protected function prepareTemplate(PHPUnit_Util_Template $template)
1571
    {
1572
    }
1573
}
1574
?>