Completed
Push — feature/other-validation ( f56062...7f372e )
by Narcotic
65:46
created

testSchemaCacheInvalidation()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 43
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 43
rs 8.8571
cc 1
eloc 23
nc 1
nop 0
1
<?php
2
/**
3
 * integration tests schema cache invalidation
4
 */
5
6
namespace Graviton\SchemaBundle\Tests\Controller;
7
8
use Graviton\TestBundle\Test\RestTestCase;
9
use Symfony\Component\HttpFoundation\Response;
10
11
/**
12
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
13
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
14
 * @link     http://swisscom.ch
15
 */
16
class SchemaCacheInvalidationTest extends RestTestCase
17
{
18
    /**
19
     * test if the invalidation of the schema cache works as expected
20
     *
21
     * @return void
22
     */
23
    public function testSchemaCacheInvalidation()
24
    {
25
26
        $client = static::createRestClient();
27
        $client->request('GET', '/schema/testcase/schema-cache-invalidation/item');
28
29
        // 'en' must exist
30
        $this->assertObjectHasAttribute('en', $client->getResults()->properties->name->properties);
31
32
        // make sure they not exist before - no properties
33
        $this->assertObjectNotHasAttribute('es', $client->getResults()->properties->name->properties);
34
        $this->assertObjectNotHasAttribute('properties', $client->getResults()->properties->apps);
35
36
        // insert new Language
37
        $newLang = (object) [
38
            'id' => 'es',
39
            'name' => (object) [
40
                'en' => 'Spanish'
41
            ]
42
        ];
43
        $client = static::createRestClient();
44
        $client->put('/i18n/language/es', $newLang);
45
46
        // insert new App
47
        $newApp = (object) [
48
            'id' => 'testapp',
49
            'name' => (object) [
50
                'en' => 'TestApp'
51
            ],
52
            'showInMenu' => true
53
        ];
54
        $client = static::createRestClient();
55
        $client->put('/core/app/testapp', $newApp);
56
57
        $client = static::createRestClient();
58
        $client->request('GET', '/schema/testcase/schema-cache-invalidation/item');
59
60
        // now, 'es' should be in the translatable schema
61
        $this->assertObjectHasAttribute('es', $client->getResults()->properties->name->properties);
62
63
        // and our testapp should be a property of the x-dynamic-key
64
        $this->assertObjectHasAttribute('testapp', $client->getResults()->properties->apps->properties);
65
    }
66
}
67