Completed
Pull Request — master (#476)
by Bruno
14:24
created

TestFixture   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 23 4
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace DoctrineORMModuleTest\Assets\Fixture;
21
22
use Doctrine\Common\DataFixtures\AbstractFixture;
23
use Doctrine\Common\Persistence\ObjectManager;
24
25
use DoctrineORMModuleTest\Assets\Entity\Test as TestEntity;
26
use DoctrineORMModuleTest\Assets\Entity\Category;
27
use DoctrineORMModuleTest\Assets\Entity\Country;
28
29
/**
30
 * Fixture that loads a constant amount of \DoctrineORMModuleTest\Assets\Entity\Test objects into the manager
31
 */
32
class TestFixture extends AbstractFixture
33
{
34
    /**
35
     * Number of instances to build when the fixture is loaded
36
     */
37
    const INSTANCES_COUNT = 100;
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public function load(ObjectManager $manager)
43
    {
44
        for ($i = 0; $i < self::INSTANCES_COUNT; $i += 1) {
45
            $instance = new TestEntity();
46
            $instance->setUsername('username');
47
            $instance->setPassword('password');
48
            $manager->persist($instance);
49
        }
50
51
        for ($i = 0; $i < self::INSTANCES_COUNT; $i += 1) {
52
            $instance = new Category();
53
            $instance->setName('category');
54
            $manager->persist($instance);
55
        }
56
57
        for ($i = 0; $i < self::INSTANCES_COUNT; $i += 1) {
58
            $instance = new Country();
59
            $instance->setName('country');
60
            $manager->persist($instance);
61
        }
62
63
        $manager->flush();
64
    }
65
}
66