File tree 4 files changed +157
-5
lines changed
4 files changed +157
-5
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ /* For licensing terms, see /license.txt */
6
+
7
+ namespace Chamilo \Tests \CoreBundle \Repository ;
8
+
9
+ use Chamilo \CoreBundle \Entity \Language ;
10
+ use Chamilo \CoreBundle \Repository \LanguageRepository ;
11
+ use Chamilo \Tests \AbstractApiTest ;
12
+ use Chamilo \Tests \ChamiloTestTrait ;
13
+
14
+ class LanguageRepositoryTest extends AbstractApiTest
15
+ {
16
+ use ChamiloTestTrait;
17
+
18
+ public function testCreate (): void
19
+ {
20
+ self ::bootKernel ();
21
+
22
+ $ em = $ this ->getManager ();
23
+ $ repo = self ::getContainer ()->get (LanguageRepository::class);
24
+ $ defaultCount = $ repo ->count ([]);
25
+ $ item = (new Language ())
26
+ ->setAvailable (true )
27
+ ->setOriginalName ('language ' )
28
+ ->setEnglishName ('language ' )
29
+ ->setIsocode ('lan ' )
30
+ ;
31
+ $ this ->assertHasNoEntityViolations ($ item );
32
+ $ em ->persist ($ item );
33
+ $ em ->flush ();
34
+
35
+ $ this ->assertSame ($ defaultCount + 1 , $ repo ->count ([]));
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ /* For licensing terms, see /license.txt */
6
+
7
+ namespace Chamilo \Tests \CoreBundle \Repository ;
8
+
9
+ use Chamilo \CoreBundle \Entity \Career ;
10
+ use Chamilo \CoreBundle \Entity \Promotion ;
11
+ use Chamilo \CoreBundle \Repository \PromotionRepository ;
12
+ use Chamilo \Tests \AbstractApiTest ;
13
+ use Chamilo \Tests \ChamiloTestTrait ;
14
+
15
+ class PromotionRepositoryTest extends AbstractApiTest
16
+ {
17
+ use ChamiloTestTrait;
18
+
19
+ public function testCreate (): void
20
+ {
21
+ self ::bootKernel ();
22
+
23
+ $ em = $ this ->getManager ();
24
+ $ repo = self ::getContainer ()->get (PromotionRepository::class);
25
+ $ defaultCount = $ repo ->count ([]);
26
+
27
+ $ career = (new Career ())
28
+ ->setName ('Doctor ' )
29
+ ;
30
+ $ em ->persist ($ career );
31
+ $ em ->flush ();
32
+
33
+ $ item = (new Promotion ())
34
+ ->setName ('2000 ' )
35
+ ->setDescription ('Promotion of 2000 ' )
36
+ ->setCareer ($ career )
37
+ ->setStatus (1 )
38
+ ;
39
+ $ this ->assertHasNoEntityViolations ($ item );
40
+ $ em ->persist ($ item );
41
+ $ em ->flush ();
42
+
43
+ $ this ->assertSame ($ defaultCount + 1 , $ repo ->count ([]));
44
+ }
45
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ /* For licensing terms, see /license.txt */
6
+
7
+ namespace Chamilo \Tests \CoreBundle \Repository ;
8
+
9
+ use Chamilo \CoreBundle \Entity \ExtraField ;
10
+ use Chamilo \CoreBundle \Entity \Tag ;
11
+ use Chamilo \CoreBundle \Repository \TagRepository ;
12
+ use Chamilo \Tests \AbstractApiTest ;
13
+ use Chamilo \Tests \ChamiloTestTrait ;
14
+
15
+ class TagRepositoryTest extends AbstractApiTest
16
+ {
17
+ use ChamiloTestTrait;
18
+
19
+ public function testCreate (): void
20
+ {
21
+ self ::bootKernel ();
22
+
23
+ $ em = $ this ->getManager ();
24
+ $ repo = self ::getContainer ()->get (TagRepository::class);
25
+ $ defaultCount = $ repo ->count ([]);
26
+
27
+ $ extraField = (new ExtraField ())
28
+ ->setDisplayText ('test ' )
29
+ ->setVariable ('test ' )
30
+ ->setExtraFieldType (ExtraField::USER_FIELD_TYPE )
31
+ ->setFieldType (\ExtraField::FIELD_TYPE_TEXT )
32
+ ;
33
+ $ em ->persist ($ extraField );
34
+ $ em ->flush ();
35
+
36
+ $ tag = (new Tag ())
37
+ ->setTag ('php ' )
38
+ ->setCount (1 )
39
+ ->setField ($ extraField )
40
+ ;
41
+ $ this ->assertHasNoEntityViolations ($ tag );
42
+ $ em ->persist ($ tag );
43
+ $ em ->flush ();
44
+
45
+ $ this ->assertSame ($ defaultCount + 1 , $ repo ->count ([]));
46
+ }
47
+ }
Original file line number Diff line number Diff line change @@ -44,14 +44,16 @@ public function testCreateFolder(): void
44
44
$ course = $ this ->createCourse ('Test ' );
45
45
46
46
// Create folder.
47
- $ resourceLinkList = [[
48
- 'cid ' => $ course ->getId (),
49
- 'visibility ' => ResourceLink::VISIBILITY_PUBLISHED ,
50
- ]];
47
+ $ resourceLinkList = [
48
+ [
49
+ 'cid ' => $ course ->getId (),
50
+ 'visibility ' => ResourceLink::VISIBILITY_PUBLISHED ,
51
+ ],
52
+ ];
51
53
52
54
$ folderName = 'folder1 ' ;
53
55
$ token = $ this ->getUserToken ([]);
54
- $ this ->createClientWithCredentials ($ token )->request (
56
+ $ response = $ this ->createClientWithCredentials ($ token )->request (
55
57
'POST ' ,
56
58
'/api/documents ' ,
57
59
[
@@ -73,6 +75,27 @@ public function testCreateFolder(): void
73
75
'title ' => $ folderName ,
74
76
'parentResourceNode ' => $ course ->getResourceNode ()->getId (),
75
77
]);
78
+
79
+ // Update.
80
+ $ id = $ response ->toArray ()['@id ' ];
81
+
82
+ $ this ->createClientWithCredentials ($ token )->request (
83
+ 'PUT ' ,
84
+ $ id ,
85
+ [
86
+ 'json ' => [
87
+ 'title ' => 'edited ' ,
88
+ ],
89
+ ]
90
+ );
91
+
92
+ $ this ->assertResponseIsSuccessful ();
93
+ $ this ->assertResponseStatusCodeSame (200 );
94
+ $ this ->assertJsonContains ([
95
+ '@context ' => '/api/contexts/Documents ' ,
96
+ '@type ' => 'Documents ' ,
97
+ 'title ' => 'edited ' ,
98
+ ]);
76
99
}
77
100
78
101
public function testUploadFile (): void
You can’t perform that action at this time.
0 commit comments