Issues (80)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/Khepin/Tests/MongoFixtureTest.php (23 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Khepin\Tests;
4
5
use \Mockery as m;
6
use Khepin\YamlFixturesBundle\Loader\YamlLoader;
7
use Khepin\Utils\BaseTestCaseMongo;
8
9
/**
10
 * @group mongo
11
 */
12
class MongoFixtureTest extends BaseTestCaseMongo
13
{
14
    protected $kernel = null;
15
16
    public function setUp()
17
    {
18
        $this->getDoctrine();
19
        $service = m::mock()->shouldReceive('lowerCaseName')->withAnyArgs()->andReturnUsing(
0 ignored issues
show
The method mock() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20
            function ($car) {
21
                    $car->setName(strtolower($car->getName()));
22
            }
23
        )->mock();
24
        $container = m::mock('Container')
0 ignored issues
show
The method shouldReceive() does not seem to exist on object<Mockery\Expectation>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
                ->shouldReceive('get')->with('my_service')->andReturn($service)
26
                ->shouldReceive('get')->withAnyArgs()->andReturn($this->doctrine)
27
                ->mock();
28
        $this->kernel = m::mock(
29
            '\Symfony\Component\HttpKernel\KernelInterface',
30
            array(
31
                    'locateResource' => __DIR__ . '/mongo/',
32
                    'getContainer'   => $container
33
            )
34
        );
35
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
36
        $loader->purgeDatabase('mongodb');
37
    }
38
39
    public function testSimpleLoading()
40
    {
41
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
42
        $loader->loadFixtures();
43
44
        $dm = $this->doctrine->getManager();
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        $cars = $dm->getRepository('Khepin\Fixture\Document\Car')->findAll();
46
        $this->assertEquals(2, count($cars));
47
        $car = $dm->getRepository('Khepin\Fixture\Document\Car')->findOneBy(array('name' => 'Mercedes'));
48
        $this->assertEquals('Mercedes', $car->getName());
49
        $date = new \DateTime('2012-01-01');
50
        $this->assertEquals($date, $car->getDatePurchased());
51
        $this->assertEquals(get_class($date), get_class($car->getDatePurchased()));
52
    }
53
54 View Code Duplication
    public function testLoadSingleFile()
0 ignored issues
show
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...
55
    {
56
        $loader = new YamlLoader($this->kernel, array('SomeBundle/cars'), 'DataFixtures');
57
        $loader->loadFixtures();
58
59
        $dm = $this->doctrine->getManager();
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
        $cars = $dm->getRepository('Khepin\Fixture\Document\Car')->findAll();
61
        $this->assertEquals(2, count($cars));
62
        $drivers = $dm->getRepository('Khepin\Fixture\Document\Driver')->findAll();
63
        $this->assertEquals(0, count($drivers));
64
    }
65
66 View Code Duplication
    public function testSingleFileLoadedOnlyOnce()
0 ignored issues
show
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...
67
    {
68
        $loader = new YamlLoader($this->kernel, array('SomeBundle/cars', 'SomeBundle'), 'DataFixtures');
69
        $loader->loadFixtures();
70
71
        $em = $this->doctrine->getManager();
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
72
        $cars = $em->getRepository('Khepin\Fixture\Document\Car')->findAll();
73
        $this->assertEquals(2, count($cars));
74
        $drivers = $em->getRepository('Khepin\Fixture\Document\Driver')->findAll();
75
        $this->assertEquals(0, count($drivers));
76
    }
77
78 View Code Duplication
    public function testPurge()
0 ignored issues
show
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...
79
    {
80
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
81
        $loader->loadFixtures();
82
        $loader->purgeDatabase('mongodb');
83
84
        $cars = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Car')->findAll();
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
85
        $this->assertEquals(count($cars), 0);
86
87
        $drivers = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Driver')->findAll();
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
        $this->assertEquals(count($drivers), 0);
89
    }
90
91 View Code Duplication
    public function testContext()
0 ignored issues
show
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...
92
    {
93
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
94
        $loader->loadFixtures('french_cars');
95
96
        $repo = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Car');
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
97
        $cars = $repo->findAll();
98
        $this->assertEquals(5, count($cars));
99
100
        $car = $repo->findOneBy(array('name' => 'Peugeot'));
101
        $this->assertEquals('Peugeot', $car->getName());
102
103
        $car = $repo->findOneBy(array('name' => 'BMW'));
104
        $this->assertEquals('BMW', $car->getName());
105
    }
106
107
    public function testReferenceOne()
108
    {
109
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
110
        $loader->loadFixtures('with_drivers', 'family_cars');
111
112
        $repo = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Driver');
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
113
        $driver = $repo->findOneBy(array('name' => 'Mom'));
114
115
        $this->assertEquals('Mercedes', $driver->getPreferredCar()->getName());
116
        $this->assertNotEquals('BMW', $driver->getPreferredCar()->getName());
117
    }
118
119
    public function testReferenceMany()
120
    {
121
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
122
        $loader->loadFixtures('with_drivers', 'family_cars');
123
124
        $repo = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Driver');
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
125
        $driver = $repo->findOneBy(array('name' => 'Mom'));
126
        $this->assertEquals($driver->getCars()->count(), 3);
127
        $cars = $driver->getCars();
128
        $car = $cars[0];
129
        $this->assertEquals('Mercedes', $car->getName());
130
        $driver = $repo->findOneBy(array('name' => 'Dad'));
131
        $this->assertEquals($driver->getCars()->count(), 3);
132
    }
133
134 View Code Duplication
    public function testServiceCalls()
0 ignored issues
show
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...
135
    {
136
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
137
        $loader->loadFixtures('service');
138
139
        $repo = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Car');
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
140
        $car = $repo->findOneBy(array('name' => 'toyota'));
141
        $this->assertTrue('toyota' === $car->getName());
142
    }
143
144 View Code Duplication
    public function testEmbedOne()
0 ignored issues
show
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...
145
    {
146
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
147
        $loader->loadFixtures('embed_one');
148
149
        $repo = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Article');
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
150
        $articles = $repo->createQueryBuilder()->getQuery()->execute();
151
        $this->assertEquals($articles->count(), 1);
152
        $article = $articles->getNext();
153
        $this->assertInstanceOf('Khepin\Fixture\Document\Article', $article);
154
        $author = $article->getAuthor();
155
        $this->assertInstanceOf('Khepin\Fixture\Document\Author', $author);
156
157
        $this->assertEquals($author->getName(), 'Paul');
158
    }
159
160 View Code Duplication
    public function testEmbedMany()
0 ignored issues
show
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...
161
    {
162
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
163
        $loader->loadFixtures('embed_many');
164
165
        $repo = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Article');
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
166
        $articles = $repo->createQueryBuilder()->getQuery()->execute();
167
        $this->assertEquals($articles->count(), 1);
168
        $article = $articles->getNext();
169
        $this->assertInstanceOf('Khepin\Fixture\Document\Article', $article);
170
        $tags = $article->getTags();
171
        $this->assertEquals('YAML', $tags[0]->getName());
172
        $this->assertEquals($tags->count(), 2);
173
    }
174
175 View Code Duplication
    public function testConstructor()
0 ignored issues
show
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...
176
    {
177
        $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures');
178
        $loader->loadFixtures('construct');
179
180
        $repo = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Car');
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
181
        $car = $repo->findOneByName('Ford');
182
        $this->assertEquals('Ford', $car->getName());
183
        $this->assertInstanceOf('\DateTime', $car->getDatePurchased());
184
185
        $repo = $this->doctrine->getManager()->getRepository('Khepin\Fixture\Document\Owner');
0 ignored issues
show
The method getManager() does not seem to exist on object<Mockery\MockInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
186
        $owner = $repo->findOneByName('Some Small Company');
187
        $this->assertEquals(1, count($owner->getOwnedCars()));
188
        $this->assertEquals('Some Small Company', $owner->getName());
189
    }
190
}
191