1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Psi\Bridge\ContentType\Doctrine\PhpcrOdm\Tests\Functional; |
4
|
|
|
|
5
|
|
|
use Psi\Bridge\ContentType\Doctrine\PhpcrOdm\Tests\Functional\Example\Article; |
6
|
|
|
|
7
|
|
|
class ScalarTest extends PhpcrOdmTestCase |
8
|
|
|
{ |
9
|
|
View Code Duplication |
public function setUp() |
|
|
|
|
10
|
|
|
{ |
11
|
|
|
$container = $this->getContainer([ |
12
|
|
|
'mapping' => [ |
13
|
|
|
Article::class => [ |
14
|
|
|
'fields' => [ |
15
|
|
|
'paragraphs' => [ |
16
|
|
|
'type' => 'collection', |
17
|
|
|
'options' => [ |
18
|
|
|
'field' => 'text', |
19
|
|
|
'field_options' => [], |
20
|
|
|
], |
21
|
|
|
], |
22
|
|
|
'numbers' => [ |
23
|
|
|
'type' => 'collection', |
24
|
|
|
'options' => [ |
25
|
|
|
'field' => 'integer', |
26
|
|
|
], |
27
|
|
|
], |
28
|
|
|
], |
29
|
|
|
], |
30
|
|
|
], |
31
|
|
|
]); |
32
|
|
|
$this->documentManager = $container->get('doctrine_phpcr.document_manager'); |
|
|
|
|
33
|
|
|
$this->initPhpcr($this->documentManager); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
View Code Duplication |
public function testStringCollection() |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
$article = new Article(); |
39
|
|
|
$article->id = '/test/article'; |
40
|
|
|
$article->title = 'Foo'; |
41
|
|
|
$article->paragraphs = ['one', 'two', 'three']; |
42
|
|
|
|
43
|
|
|
$this->documentManager->persist($article); |
44
|
|
|
$this->documentManager->flush(); |
45
|
|
|
$this->documentManager->clear(); |
46
|
|
|
|
47
|
|
|
$article = $this->documentManager->find(null, '/test/article'); |
48
|
|
|
$this->assertSame(['one', 'two', 'three'], $article->paragraphs); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
View Code Duplication |
public function testIntegerCollection() |
|
|
|
|
52
|
|
|
{ |
53
|
|
|
$article = new Article(); |
54
|
|
|
$article->id = '/test/article'; |
55
|
|
|
$article->title = 'Foo'; |
56
|
|
|
$article->numbers = ['12', '13', '14']; |
57
|
|
|
|
58
|
|
|
$this->documentManager->persist($article); |
59
|
|
|
$this->documentManager->flush(); |
60
|
|
|
$this->documentManager->clear(); |
61
|
|
|
|
62
|
|
|
$article = $this->documentManager->find(null, '/test/article'); |
63
|
|
|
$this->assertSame([12, 13, 14], $article->numbers); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
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.