Completed
Push — master ( 0e2bb1...d48330 )
by WEBEWEB
02:01
created

TestFixtures   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 6
dl 0
loc 90
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getImages() 0 8 1
A getNavigationTree() 0 30 1
A getUsers() 0 17 1
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\Tests\Fixtures;
13
14
use DateInterval;
15
use DateTime;
16
use Exception;
17
use Symfony\Component\Security\Core\User\UserInterface;
18
use WBW\Bundle\CoreBundle\Navigation\DividerNode;
19
use WBW\Bundle\CoreBundle\Navigation\HeaderNode;
20
use WBW\Bundle\CoreBundle\Navigation\NavigationInterface;
21
use WBW\Bundle\CoreBundle\Navigation\NavigationNode;
22
use WBW\Bundle\CoreBundle\Navigation\NavigationTree;
23
use WBW\Bundle\CoreBundle\Tests\Fixtures\Entity\TestUser;
24
25
/**
26
 * Test fixtures.
27
 *
28
 * @author webeweb <https://github.com/webeweb/>
29
 * @package WBW\Bundle\CoreBundle\Tests\Fixtures
30
 */
31
class TestFixtures {
32
33
    /**
34
     * Get the images.
35
     *
36
     * @return string[]
37
     */
38
    public static function getImages(): array {
39
        return [
40
            getcwd() . "/Tests/Fixtures/Model/TestImage_1920x1037.jpg",
41
            getcwd() . "/Tests/Fixtures/Model/TestImage_1920x1037.png",
42
            getcwd() . "/Tests/Fixtures/Model/TestImage_1920x1920.png",
43
            getcwd() . "/Tests/Fixtures/Model/TestImage_1920x3554.png",
44
        ];
45
    }
46
47
    /**
48
     * Get a navigation tree.
49
     * GitHub
50
     * |- AdminBSB Material Design bundle
51
     * |- Bootstrap bundle
52
     * |- EDM bundle
53
     * |- Highcharts bundle
54
     * |- jQuery DataTables bundle
55
     * |- jQuery QueryBuilder bundle
56
     * |- SyntaxHighlighter bundle
57
     * |- Core library
58
     * |- cURL library
59
     * |- FTP library
60
     * |- fPDF library
61
     * |- SkiData library
62
     * |- sMsmode library
63
     *
64
     * @return NavigationTree Returns the navigation tree.
65
     */
66
    public static function getNavigationTree(): NavigationTree {
67
68
        $tree = new NavigationTree("tree");
69
70
        $tree->addNode(new NavigationNode("GitHub", null, NavigationInterface::NAVIGATION_HREF_DEFAULT));
71
72
        $tree->getLastNode()->addNode(new HeaderNode("GitHub"));
73
        $tree->getLastNode()->addNode(new DividerNode("Bundles"));
74
        $tree->getLastNode()->addNode(new NavigationNode("AdminBSB Material Design bundle", null, "https://github.com/webeweb/adminbsb-material-design-bundle"));
75
        $tree->getLastNode()->addNode(new NavigationNode("Bootstrap bundle", null, "https://github.com/webeweb/bootstrap-bundle"));
76
        $tree->getLastNode()->addNode(new NavigationNode("Core bundle", null, "https://github.com/webeweb/core-bundle"));
77
        $tree->getLastNode()->addNode(new NavigationNode("EDM bundle", null, "https://github.com/webeweb/edm-bundle"));
78
        $tree->getLastNode()->addNode(new NavigationNode("HaveIBeenPwnd bundle", null, "https://github.com/webeweb/haveibeenpwned-bundle"));
79
        $tree->getLastNode()->addNode(new NavigationNode("Highcharts bundle", null, "https://github.com/webeweb/highcharts-bundle"));
80
        $tree->getLastNode()->addNode(new NavigationNode("jQuery DataTables bundle", null, "https://github.com/webeweb/jquery-datatables-bundle"));
81
        $tree->getLastNode()->addNode(new NavigationNode("jQuery QueryBuilder bundle", null, "https://github.com/webeweb/jquery-querybuilder-bundle"));
82
        $tree->getLastNode()->addNode(new NavigationNode("OpenData bundle", null, "https://github.com/webeweb/opendata-bundle"));
83
        $tree->getLastNode()->addNode(new NavigationNode("SyntaxHighlighter bundle", null, "https://github.com/webeweb/syntaxhighlighter-bundle"));
84
        $tree->getLastNode()->addNode(new DividerNode("Libraries"));
85
        $tree->getLastNode()->addNode(new NavigationNode("Chart accounts library", null, "https://github.com/webeweb/chart-accounts-library"));
86
        $tree->getLastNode()->addNode(new NavigationNode("Core library", null, "https://github.com/webeweb/core-library"));
87
        $tree->getLastNode()->addNode(new NavigationNode("cURL library", null, "https://github.com/webeweb/curl-library"));
88
        $tree->getLastNode()->addNode(new NavigationNode("FTP library", null, "https://github.com/webeweb/ftp-library"));
89
        $tree->getLastNode()->addNode(new NavigationNode("fPDF library", null, "https://github.com/webeweb/fpdf-library"));
90
        $tree->getLastNode()->addNode(new NavigationNode("HaveIBeenPwnd library", null, "https://github.com/webeweb/haveibeenpwned-library"));
91
        $tree->getLastNode()->addNode(new NavigationNode("SkiData library", null, "https:\/\/github\.com\/webeweb\/skidata-library", NavigationInterface::NAVIGATION_MATCHER_REGEXP));
92
        $tree->getLastNode()->addNode(new NavigationNode("sMsmode library", null, "https://github.com/webeweb/smsmode-library", NavigationInterface::NAVIGATION_MATCHER_ROUTER));
93
94
        return $tree;
95
    }
96
97
    /**
98
     * Get the users.
99
     *
100
     * @return UserInterface[] Returns the users.
101
     * @throws Exception Throws an exception if an error occurs.
102
     */
103
    public static function getUsers(): array {
104
105
        $fixtures   = [];
106
        $fixtures[] = (new TestUser())
107
            ->setUsername("webeweb")
108
            ->setUsernameCanonical("webeweb")
109
            ->setEmail("[email protected]")
110
            ->setEmailCanonical("[email protected]")
111
            ->setEnabled(true)
112
            ->setSalt("salt")
113
            ->setPlainPassword("github")
114
            ->setConfirmationToken("confirmationToken")
115
            ->setLastLogin((new DateTime())->sub(new DateInterval("P1D")))
116
            ->setPasswordRequestedAt(new DateTime());
117
118
        return $fixtures;
119
    }
120
}
121