GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 491c83...9c1c8e )
by Florian
02:38
created

DocumentToEntityMapperTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 6
dl 0
loc 58
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A getDocumentToEntityMapper() 0 8 1
A testGetEntity() 0 19 1
A getUsedEntityFixtures() 0 5 1
1
<?php
2
3
/*
4
 * This file is part of the Stinger Entity Search package.
5
 *
6
 * (c) Oliver Kotte <[email protected]>
7
 * (c) Florian Meyer <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
namespace StingerSoft\EntitySearchBundle\Tests\Services;
13
14
use Doctrine\Common\Persistence\AbstractManagerRegistry;
15
use StingerSoft\EntitySearchBundle\Services\Mapping\DocumentToEntityMapper;
16
use StingerSoft\EntitySearchBundle\Tests\AbstractORMTestCase;
17
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Beer;
18
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Potato;
19
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Whiskey;
20
use StingerSoft\EntitySearchBundle\Model\Document;
21
22
class DocumentToEntityMapperTest extends AbstractORMTestCase {
23
24
	/**
25
	 *
26
	 * {@inheritDoc}
27
	 *
28
	 * @see PHPUnit_Framework_TestCase::setUp()
29
	 */
30
	public function setUp() {
31
		parent::setUp();
32
		$this->getMockSqliteEntityManager();
33
	}
34
35
	/**
36
	 *
37
	 * @return \StingerSoft\EntitySearchBundle\Services\Mapping\DocumentToEntityMapper
38
	 */
39
	protected function getDocumentToEntityMapper() {
40
		$managerMock = $this->getMockBuilder(AbstractManagerRegistry::class)->setMethods(array(
41
			'getManagerForClass' 
42
		))->disableOriginalConstructor()->getMockForAbstractClass();
43
		$managerMock->expects($this->once())->method('getManagerForClass')->will($this->returnValue($this->em));
44
		$eh = new DocumentToEntityMapper($managerMock);
45
		return $eh;
46
	}
47
48
	public function testGetEntity() {
49
		$beer = new Beer();
50
		$beer->setTitle('Hemelinger');
51
		$this->em->persist($beer);
52
		$this->em->flush();
53
		
54
		$document = $this->getMockBuilder(Document::class)->setMethods(array(
55
			'getEntityClass',
56
			'getEntityId',
57
		))->getMockForAbstractClass();
58
		$document->expects($this->once())->method('getEntityClass')->will($this->returnValue(Beer::class));
59
		$document->expects($this->once())->method('getEntityId')->will($this->returnValue($beer->getId()));
60
		
61
		$eh = $this->getDocumentToEntityMapper();
62
		
63
		$entity = $eh->getEntity($document);
64
		$this->assertEquals($beer, $entity);
65
		
66
	}
67
68
	/**
69
	 *
70
	 * {@inheritDoc}
71
	 *
72
	 * @see \StingerSoft\EntitySearchBundle\Tests\AbstractTestCase::getUsedEntityFixtures()
73
	 */
74
	protected function getUsedEntityFixtures() {
75
		return array(
76
			Beer::class
77
		);
78
	}
79
}