Completed
Push — master ( 300f7c...ac8da7 )
by Joschi
06:40
created

RepositoryTest::testRepositoryBuild()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 9.0856
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
/**
4
 * apparat-dev
5
 *
6
 * @category    Apparat
7
 * @package     Apparat\Server
8
 * @subpackage  Apparat\Dev\Tests
9
 * @author      Joschi Kuphal <[email protected]> / @jkphl
10
 * @copyright   Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl
11
 * @license     http://opensource.org/licenses/MIT The MIT License (MIT)
12
 */
13
14
/***********************************************************************************
15
 *  The MIT License (MIT)
16
 *
17
 *  Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl
18
 *
19
 *  Permission is hereby granted, free of charge, to any person obtaining a copy of
20
 *  this software and associated documentation files (the "Software"), to deal in
21
 *  the Software without restriction, including without limitation the rights to
22
 *  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
23
 *  the Software, and to permit persons to whom the Software is furnished to do so,
24
 *  subject to the following conditions:
25
 *
26
 *  The above copyright notice and this permission notice shall be included in all
27
 *  copies or substantial portions of the Software.
28
 *
29
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
 *  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
32
 *  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
33
 *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34
 *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
 ***********************************************************************************/
36
37
namespace Apparat\Dev\Tests;
38
39
use Apparat\Dev\Ports\Repository;
40
use Apparat\Object\Ports\Object;
41
42
/**
43
 * Repository test
44
 *
45
 * @package Apparat\Dev
46
 * @subpackage Apparat\Dev\Tests
47
 */
48
class RepositoryTest extends AbstractTest
49
{
50
    /**
51
     * Test the generation of a test repository
52
     *
53
     * @expectedException \Apparat\Dev\Ports\InvalidArgumentsException
54
     * @expectedExceptionCode 1464974472
55
     */
56
    public function testRepositoryBuildInvalidRoot()
57
    {
58
        Repository::generate(null, []);
59
    }
60
61
    /**
62
     * Test the generation of a test repository with an empty object configuration
63
     *
64
     * @expectedException \Apparat\Dev\Ports\InvalidArgumentsException
65
     * @expectedExceptionCode 1464974779
66
     */
67
    public function testRepositoryBuildInvalidObjectConfig()
68
    {
69
        Repository::generate($this->createTemporaryFileName(), [], Repository::FLAG_CREATE_ROOT_DIRECTORY);
70
    }
71
72
    /**
73
     * Test the generation of a test repository with zero object count
74
     *
75
     * @expectedException \Apparat\Dev\Ports\InvalidArgumentsException
76
     * @expectedExceptionCode 1464975382
77
     */
78
    public function testRepositoryBuildEmptyObjectCount()
79
    {
80
        $objectConfig = [
81
            Object::ARTICLE => []
82
        ];
83
        Repository::generate($this->createTemporaryFileName(), $objectConfig, Repository::FLAG_CREATE_ROOT_DIRECTORY);
84
    }
85
86
    /**
87
     * Test the generation of a test repository
88
     */
89
    public function testRepositoryBuild()
90
    {
91
        $objectConfig = [
92
            Object::ARTICLE => [
93
                Repository::COUNT => 100,
94
                Repository::HIDDEN => true,
95
                Repository::DRAFTS => true,
96
            ],
97
            Object::EVENT => [
98
                Repository::COUNT => 100,
99
            ],
100
            Object::CONTACT => [
101
                Repository::COUNT => 100,
102
                Repository::REVISIONS => -3,
103
                Repository::DRAFTS => true,
104
            ]
105
        ];
106
        Repository::generate(
107
            sys_get_temp_dir().DIRECTORY_SEPARATOR.'apparat-test',
108
            $objectConfig,
109
            Repository::FLAG_CREATE_ROOT_DIRECTORY | Repository::FLAG_EMPTY_FILES
110
        );
111
    }
112
}