1<?php
2/*
3 * This file is part of PHPUnit.
4 *
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11class Extensions_RepeatedTestTest extends PHPUnit_Framework_TestCase
12{
13    protected $suite;
14
15    public function __construct()
16    {
17        $this->suite = new PHPUnit_Framework_TestSuite;
18
19        $this->suite->addTest(new Success);
20        $this->suite->addTest(new Success);
21    }
22
23    public function testRepeatedOnce()
24    {
25        $test = new PHPUnit_Extensions_RepeatedTest($this->suite, 1);
26        $this->assertCount(2, $test);
27
28        $result = $test->run();
29        $this->assertCount(2, $result);
30    }
31
32    public function testRepeatedMoreThanOnce()
33    {
34        $test = new PHPUnit_Extensions_RepeatedTest($this->suite, 3);
35        $this->assertCount(6, $test);
36
37        $result = $test->run();
38        $this->assertCount(6, $result);
39    }
40
41    public function testRepeatedZero()
42    {
43        $test = new PHPUnit_Extensions_RepeatedTest($this->suite, 0);
44        $this->assertCount(0, $test);
45
46        $result = $test->run();
47        $this->assertCount(0, $result);
48    }
49
50    public function testRepeatedNegative()
51    {
52        try {
53            $test = new PHPUnit_Extensions_RepeatedTest($this->suite, -1);
54        } catch (Exception $e) {
55            return;
56        }
57
58        $this->fail('Should throw an Exception');
59    }
60}
61