1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Overwatch\ResultBundle\Tests\Entity; |
4
|
|
|
|
5
|
|
|
use Overwatch\ResultBundle\DataFixtures\ORM\TestResultFixtures; |
6
|
|
|
use Overwatch\TestBundle\DataFixtures\ORM\TestFixtures; |
7
|
|
|
use Overwatch\UserBundle\Tests\Base\DatabaseAwareTestCase; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* TestResultRepository |
11
|
|
|
* Functional tests for TestResultRepository |
12
|
|
|
*/ |
13
|
|
|
class TestResultRepositoryTest extends DatabaseAwareTestCase |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var Overwatch\ResultBundle\Entity\TestResultRepository |
17
|
|
|
*/ |
18
|
|
|
private $repo; |
19
|
|
|
|
20
|
|
|
public function setUp() |
21
|
|
|
{ |
22
|
|
|
parent::setUp(); |
23
|
|
|
$this->repo = $this->em->getRepository('OverwatchResultBundle:TestResult'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testGetResults() |
27
|
|
|
{ |
28
|
|
|
$results = $this->repo->getResults(['test' => TestFixtures::$tests['test-1']]); |
29
|
|
|
|
30
|
|
|
$this->assertInternalType('array', $results); |
31
|
|
|
$this->assertCount(3, $results); |
32
|
|
|
$this->assertCollectionContainsObject(TestResultFixtures::$results['result-1'], $results); |
33
|
|
|
$this->assertCollectionContainsObject(TestResultFixtures::$results['result-2'], $results); |
34
|
|
|
$this->assertCollectionContainsObject(TestResultFixtures::$results['result-3'], $results); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testGetResultsPagination() |
38
|
|
|
{ |
39
|
|
|
$results = $this->repo->getResults(['test' => TestFixtures::$tests['test-1']], 1); |
40
|
|
|
$this->assertInternalType('array', $results); |
41
|
|
|
$this->assertCount(1, $results); |
42
|
|
|
$this->assertCollectionContainsObject(TestResultFixtures::$results['result-3'], $results); |
43
|
|
|
|
44
|
|
|
$results = $this->repo->getResults(['test' => TestFixtures::$tests['test-1']], 1, 2); |
45
|
|
|
$this->assertInternalType('array', $results); |
46
|
|
|
$this->assertCount(1, $results); |
47
|
|
|
$this->assertCollectionContainsObject(TestResultFixtures::$results['result-2'], $results); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testGetResultsOlderThan() |
51
|
|
|
{ |
52
|
|
|
$cutoff = new \DateTime('-90 minutes'); |
53
|
|
|
$results = $this->repo->getResultsOlderThan($cutoff); |
54
|
|
|
$this->assertEquals(TestResultFixtures::$results['result-1']->getId(), $results->next()[0]->getId()); |
55
|
|
|
$this->assertFalse($results->next()); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|