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 ( a42b47...a111ac )
by Florian
03:12
created

DummySearchServiceTest::testRemoveDocument()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 15
loc 15
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
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\Tests\AbstractORMTestCase;
15
use StingerSoft\EntitySearchBundle\Services\DummySearchService;
16
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Beer;
17
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Potato;
18
19
class DummySearchServiceTest extends AbstractORMTestCase {
20
21
	/**
22
	 *
23
	 * {@inheritDoc}
24
	 *
25
	 * @see PHPUnit_Framework_TestCase::setUp()
26
	 */
27
	public function setUp() {
28
		parent::setUp();
29
		$this->getMockSqliteEntityManager();
30
	}
31
32
	/**
33
	 *
34
	 * @return \StingerSoft\EntitySearchBundle\Services\DummySearchService
35
	 */
36
	protected function getSearchService() {
37
		$service = new DummySearchService();
38
		$service->setObjectManager($this->em);
39
		return $service;
40
	}
41
42 View Code Duplication
	public function testSaveDocument() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
		$beer = new Beer();
44
		$beer->setTitle('Hemelinger');
45
		$this->em->persist($beer);
46
		$this->em->flush();
47
		
48
		$service = $this->getSearchService();
49
		$document = $service->createEmptyDocumentFromEntity($beer);
50
		$this->assertAttributeCount(0, 'index', $service);
51
		$service->saveDocument($document);
52
		$this->assertAttributeCount(1, 'index', $service);
53
		
54
		$service->clearIndex();
55
		$this->assertAttributeCount(0, 'index', $service);
56
	}
57
58 View Code Duplication
	public function testRemoveDocument() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
		$beer = new Beer();
60
		$beer->setTitle('Hemelinger');
61
		$this->em->persist($beer);
62
		$this->em->flush();
63
		
64
		$service = $this->getSearchService();
65
		$document = $service->createEmptyDocumentFromEntity($beer);
66
		$this->assertAttributeCount(0, 'index', $service);
67
		$service->saveDocument($document);
68
		$this->assertAttributeCount(1, 'index', $service);
69
		
70
		$service->removeDocument($document);
71
		$this->assertAttributeCount(0, 'index', $service);
72
	}
73
74
	public function testAutocompletion() {
75
		$beer = new Beer();
76
		$beer->setTitle('Hemelinger');
77
		$this->em->persist($beer);
78
		$this->em->flush();
79
		
80
		$service = $this->getSearchService();
81
		$document = $service->createEmptyDocumentFromEntity($beer);
82
		$this->assertAttributeCount(0, 'index', $service);
83
		$beer->indexEntity($document);
84
		$service->saveDocument($document);
85
		$this->assertAttributeCount(1, 'index', $service);
86
		
87
		$suggests = $service->autocomplete('He');
88
		$this->count(1, $suggests);
0 ignored issues
show
Unused Code introduced by
The call to DummySearchServiceTest::count() has too many arguments starting with 1.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Unused Code introduced by
The call to the method StingerSoft\EntitySearch...rchServiceTest::count() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
89
		$this->assertContains($beer->getTitle(), $suggests);
90
		
91
	}
92
93
	/**
94
	 *
95
	 * {@inheritDoc}
96
	 *
97
	 * @see \StingerSoft\EntitySearchBundle\Tests\AbstractTestCase::getUsedEntityFixtures()
98
	 */
99
	protected function getUsedEntityFixtures() {
100
		return array(
101
			Beer::class,
102
			Potato::class 
103
		);
104
	}
105
}