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 ( 926faa...eb8df6 )
by Florian
04:05
created

EntityHandlerTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 9

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 9
c 1
b 0
f 1
lcom 2
cbo 9
dl 0
loc 117
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A getEntityHandler() 0 4 1
A testFuckedUpConfiguration() 0 6 1
A testFuckedUpConfigurationWithoutMapping() 0 8 1
A testFuckedUpConfigurationWithoutModel() 0 7 1
A testFuckedUpConfigurationWithoutPersistance() 0 10 1
A testIsIndexable() 0 6 1
B testCreateDocument() 0 26 1
A getUsedEntityFixtures() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the Stinger Enity 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 StingerSoft\EntitySearchBundle\Model\Document;
15
use StingerSoft\EntitySearchBundle\Services\DummySearchService;
16
use StingerSoft\EntitySearchBundle\Services\EntityHandler;
17
use StingerSoft\EntitySearchBundle\Tests\AbstractORMTestCase;
18
use StingerSoft\EntitySearchBundle\Tests\DependencyInjection\StingerSoftEntitySearchExtensionTest;
19
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Beer;
20
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Potato;
21
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Whiskey;
22
use StingerSoft\EntitySearchBundle\Services\AbstractSearchService;
23
24
class EntityHandlerTest extends AbstractORMTestCase {
25
26
	/**
27
	 *
28
	 * {@inheritDoc}
29
	 *
30
	 * @see PHPUnit_Framework_TestCase::setUp()
31
	 */
32
	public function setUp() {
33
		parent::setUp();
34
		$this->getMockSqliteEntityManager();
35
	}
36
37
	/**
38
	 *
39
	 * @return \StingerSoft\EntitySearchBundle\Services\EntityHandler
40
	 */
41
	protected function getEntityHandler() {
42
		$eh = new EntityHandler(new DummySearchService(), StingerSoftEntitySearchExtensionTest::$mockConfiguration['stinger_soft.entity_search']['types']);
43
		return $eh;
44
	}
45
46
	/**
47
	 * @expectedException \InvalidArgumentException
48
	 */
49
	public function testFuckedUpConfiguration() {
50
		$searchService = $this->getMockBuilder(AbstractSearchService::class)->getMockForAbstractClass();
51
		new EntityHandler($searchService, array(
52
			'beer' => array()
53
		));
54
	}
55
	
56
	/**
57
	 * @expectedException \InvalidArgumentException
58
	 */
59
	public function testFuckedUpConfigurationWithoutMapping() {
60
		$searchService = $this->getMockBuilder(AbstractSearchService::class)->getMockForAbstractClass();
61
		new EntityHandler($searchService, array(
62
			'beer' => array('persistance' => array(
63
				'model' => Beer::class
64
			))
65
		));
66
	}
67
	
68
	/**
69
	 * @expectedException \InvalidArgumentException
70
	 */
71
	public function testFuckedUpConfigurationWithoutModel() {
72
		$searchService = $this->getMockBuilder(AbstractSearchService::class)->getMockForAbstractClass();
73
		new EntityHandler($searchService, array(
74
			'beer' => array('persistance' => array(
75
			))
76
		));
77
	}
78
	
79
	/**
80
	 * @expectedException \InvalidArgumentException
81
	 */
82
	public function testFuckedUpConfigurationWithoutPersistance() {
83
		$searchService = $this->getMockBuilder(AbstractSearchService::class)->getMockForAbstractClass();
84
		new EntityHandler($searchService, array(
85
			'beer' => array('mapping' => array(
86
				'title' => array(
87
					'propertyPath' => false
88
				)
89
			))
90
		));
91
	}
92
93
	public function testIsIndexable() {
94
		$eh = $this->getEntityHandler();
95
		$this->assertTrue($eh->isIndexable(new Beer()));
96
		$this->assertFalse($eh->isIndexable(new Potato()));
97
		$this->assertTrue($eh->isIndexable(new Whiskey()));
98
	}
99
100
	public function testCreateDocument() {
101
		$eh = $this->getEntityHandler();
102
		
103
		$beer = new Beer();
104
		$beer->setTitle('Hemelinger');
105
		$this->em->persist($beer);
106
		$this->em->flush();
107
		$document = $eh->createDocument($this->em, $beer);
108
		$this->assertInstanceOf(Document::class, $document);
109
		$this->assertEquals('Hemelinger', $document->getFieldValue(Document::FIELD_TITLE));
110
		
111
		$whiskey = new Whiskey();
112
		$whiskey->setTitle('Laphroaig');
113
		$this->em->persist($whiskey);
114
		$this->em->flush();
115
		$document = $eh->createDocument($this->em, $whiskey);
116
		$this->assertInstanceOf(Document::class, $document);
117
		$this->assertEquals('Laphroaig', $document->getFieldValue(Document::FIELD_TITLE));
118
		
119
		$potato = new Potato();
120
		$potato->setTitle('Erna');
121
		$this->em->persist($potato);
122
		$this->em->flush();
123
		$document = $eh->createDocument($this->em, $potato);
124
		$this->assertFalse($document);
125
	}
126
127
	/**
128
	 *
129
	 * {@inheritDoc}
130
	 *
131
	 * @see \StingerSoft\EntitySearchBundle\Tests\AbstractTestCase::getUsedEntityFixtures()
132
	 */
133
	protected function getUsedEntityFixtures() {
134
		return array(
135
			Beer::class,
136
			Potato::class,
137
			Whiskey::class 
138
		);
139
	}
140
}