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 ( 1d39d2...8b424e )
by Florian
02:40
created

QueryTypeTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testInitialCall() 0 16 1
B testWithNotExistingFacets() 0 31 1
A testWithResult() 0 54 2
A getExtensions() 0 8 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;
13
14
use Symfony\Component\Form\Test\TypeTestCase;
15
use StingerSoft\EntitySearchBundle\Form\QueryType;
16
use StingerSoft\EntitySearchBundle\Form\FacetType;
17
use StingerSoft\EntitySearchBundle\Model\Query;
18
use Symfony\Component\Form\PreloadedExtension;
19
use StingerSoft\EntitySearchBundle\Model\Document;
20
use StingerSoft\EntitySearchBundle\Model\ResultSetAdapter;
21
use StingerSoft\EntitySearchBundle\Model\Result\FacetSetAdapter;
22
23
class QueryTypeTest extends TypeTestCase {
24
25
	public function testInitialCall() {
26
		$form = $this->factory->create(QueryType::class);
27
		
28
		$query = new Query('Hemelinger');
29
		
30
		$formData = array(
31
			'searchTerm' => 'Hemelinger' 
32
		);
33
		
34
		// submit the data to the form directly
35
		$form->submit($formData);
36
		
37
		$this->assertTrue($form->isSynchronized());
38
		$this->assertTrue($form->isValid());
39
		$this->assertEquals($query, $form->getData());
40
	}
41
42
	public function testWithNotExistingFacets() {
43
		$query = new Query('Hemelinger', array(), array(
44
			Document::FIELD_TYPE 
45
		));
46
		
47
		$form = $this->factory->create(QueryType::class, $query, array(
48
			'used_facets' => $query->getUsedFacets() 
49
		));
50
		
51
		$expectedQuery = new Query('Hemelinger', array(
52
			Document::FIELD_TYPE => array(
53
				'\StingerSoft\TestBundle\Entity\Test' 
54
			) 
55
		), array(
56
			Document::FIELD_TYPE 
57
		));
58
		
59
		$formData = array(
60
			'searchTerm' => 'Hemelinger',
61
			'facet_type' => array(
62
				'\StingerSoft\TestBundle\Entity\Test' 
63
			) 
64
		);
65
		
66
		// submit the data to the form directly
67
		$form->submit($formData);
68
		
69
		$this->assertTrue($form->isSynchronized());
70
		$this->assertTrue($form->isValid());
71
		$this->assertEquals($expectedQuery, $form->getData());
72
	}
73
74
	public function testWithResult() {
75
		$query = new Query('Hemelinger', array(
76
			Document::FIELD_TYPE => array(
77
				'\StingerSoft\TestBundle\Entity\Test' 
78
			) 
79
		), array(
80
			Document::FIELD_TYPE 
81
		));
82
		
83
		$result = new ResultSetAdapter();
84
		$typeFacets = new FacetSetAdapter();
85
		$typeFacets->addFacetValue(Document::FIELD_TYPE, '\StingerSoft\TestBundle\Entity\Test');
86
		$typeFacets->addFacetValue(Document::FIELD_TYPE, '\StingerSoft\TestBundle\Entity\TestNew');
87
		$result->setFacets($typeFacets);
88
		
89
		$form = $this->factory->create(QueryType::class, $query, array(
90
			'used_facets' => $query->getUsedFacets(),
91
			'result' => $result 
92
		));
93
		
94
		$expectedQuery = new Query('Hemelinger', array(
95
			Document::FIELD_TYPE => array(
96
				'\StingerSoft\TestBundle\Entity\Test' 
97
			) 
98
		), array(
99
			Document::FIELD_TYPE 
100
		));
101
		
102
		$formData = array(
103
			'searchTerm' => 'Hemelinger',
104
			'facet_type' => array(
105
				'\StingerSoft\TestBundle\Entity\Test' 
106
			) 
107
		);
108
		
109
		// submit the data to the form directly
110
		$form->submit($formData);
111
		
112
		$this->assertTrue($form->isSynchronized());
113
		$this->assertTrue($form->isValid());
114
		$this->assertEquals($expectedQuery, $form->getData());
115
		
116
		$view = $form->createView();
117
		$children = $view->children;
118
		
119
		foreach(array_keys($formData) as $key) {
120
			$this->assertArrayHasKey($key, $children);
121
		}
122
		
123
		$typeForm = $view->offsetGet('facet_type');
124
		$this->assertEquals(2, $typeForm->count());
125
		$this->assertContains('\StingerSoft\TestBundle\Entity\Test', $typeForm->vars['value']);
126
		$this->assertCount(2, $typeForm->vars['choices']);
127
	}
128
129
	/**
130
	 *
131
	 * {@inheritDoc}
132
	 *
133
	 * @see \Symfony\Component\Form\Test\FormIntegrationTestCase::getExtensions()
134
	 */
135
	protected function getExtensions() {
136
		return array(
137
			new PreloadedExtension(array(
138
				new QueryType(),
139
				new FacetType() 
140
			), array()) 
141
		);
142
	}
143
}