Completed
Push — feature/EVO-9770-doc-version-c... ( cb03f2 )
by
unknown
09:55
created

VersioningDocumentsTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 15
loc 15
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
/**
3
 * EmbeddingDocumentsTest class file
4
 */
5
6
namespace Graviton\CoreBundle\Tests\Controller;
7
8
use GravitonDyn\VersioningEntityBundle\DataFixtures\MongoDB\LoadVersioningEntityData;
9
use Symfony\Component\HttpFoundation\Response;
10
use Graviton\TestBundle\Test\RestTestCase;
11
12
/**
13
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
14
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
15
 * @link     http://swisscom.ch
16
 */
17
class VersioningDocumentsTest extends RestTestCase
18
{
19
    /**
20
     * load fixtures
21
     *
22
     * @return void
23
     */
24 View Code Duplication
    public function setUp()
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...
25
    {
26
27
        if (!class_exists(LoadVersioningEntityData::class)) {
28
            $this->markTestSkipped('Test definitions are not loaded');
29
        }
30
31
        $this->loadFixtures(
32
            [
33
                LoadVersioningEntityData::class
34
            ],
35
            null,
36
            'doctrine_mongodb'
37
        );
38
    }
39
40
    /**
41
     * Test Document as embedded
42
     *
43
     * @return void
44
     */
45 View Code Duplication
    public function testPut()
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...
46
    {
47
        // check document
48
        $client = static::createRestClient();
49
        $client->request('GET', '/testcase/versioning-entity/one');
50
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
51
        $original = $client->getResults();
52
        /* not working yet ...
53
        // Let's change something
54
        $original->data = "one-one";
55
56
        $client = static::createRestClient();
57
        $client->put('/testcase/versioning-entity/one', $original);
58
        $this->assertEquals(Response::HTTP_NO_CONTENT, $client->getResponse()->getStatusCode());
59
60
        $client->request('GET', '/testcase/versioning-entity/one');
61
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
62
63
        $original2 = $client->getResults();
64
        $this->assertEquals("one-one", $original2->data, json_encode($original2));
65
        $this->assertEquals(2, $original2->version, json_encode($original2));
66
67
        // Let's change something, version should be possible
68
        $original->data = "one";
69
        $original->version = 1;
70
71
        $client = static::createRestClient();
72
        $client->put('/testcase/versioning-entity/one', $original);
73
        $this->assertEquals(Response::HTTP_NO_CONTENT, $client->getResponse()->getStatusCode());
74
        $original3 = $client->getResults();
75
        // Version should be updated, not be 1.
76
        $this->assertEquals(3, $original3->version, json_encode($original3));
77
78
        */
79
    }
80
}
81