3
3
namespace OroCRM \Bundle \ContactBundle \Tests \Functional \Api \Rest ;
4
4
5
5
use Oro \Bundle \TestFrameworkBundle \Test \WebTestCase ;
6
+ use OroCRM \Bundle \ChannelBundle \Entity \Channel ;
6
7
7
8
/**
8
9
* @outputBuffering enabled
@@ -13,7 +14,7 @@ class ChannelApiControllerTest extends WebTestCase
13
14
protected function setUp ()
14
15
{
15
16
$ this ->initClient ([], $ this ->generateWsseAuthHeader ());
16
- $ this ->loadFixtures (['OroCRM\Bundle\ChannelBundle\Tests\Functional\Fixture\LoadChannel ' ]);
17
+ $ this ->loadFixtures (['OroCRM\Bundle\ChannelBundle\Tests\Functional\Fixture\LoadChannels ' ]);
17
18
}
18
19
19
20
public function testCget ()
@@ -23,6 +24,49 @@ public function testCget()
23
24
24
25
$ channels = $ this ->getJsonResponseContent ($ this ->client ->getResponse (), 200 );
25
26
27
+ $ this ->assertNotEmpty ($ channels );
28
+ $ this ->assertCount (2 , $ channels );
29
+ }
30
+
31
+ public function testCgetWithActiveFilter ()
32
+ {
33
+ /** @var Channel $activeChannel */
34
+ $ activeChannel = $ this ->getReference ('channel_1 ' );
35
+
36
+ /** @var Channel $inactiveChannel */
37
+ $ inactiveChannel = $ this ->getReference ('channel_2 ' );
38
+
39
+ //fetch active channels
40
+ $ url = $ this ->getUrl ('orocrm_api_get_channels ' , ['active ' => 'false ' ]);
41
+ $ this ->client ->request ('GET ' , $ url );
42
+
43
+ $ channels = $ this ->getJsonResponseContent ($ this ->client ->getResponse (), 200 );
44
+
45
+ $ this ->assertNotEmpty ($ channels );
46
+ $ this ->assertCount (1 , $ channels );
47
+ $ this ->assertEquals ($ channels [0 ]['name ' ], $ inactiveChannel ->getName ());
48
+
49
+ //fetch inactive channels
50
+ $ url = $ this ->getUrl ('orocrm_api_get_channels ' , ['active ' => 'true ' ]);
51
+ $ this ->client ->request ('GET ' , $ url );
52
+
53
+ $ channels = $ this ->getJsonResponseContent ($ this ->client ->getResponse (), 200 );
54
+
55
+ $ this ->assertNotEmpty ($ channels );
56
+ $ this ->assertCount (1 , $ channels );
57
+ $ this ->assertEquals ($ channels [0 ]['name ' ], $ activeChannel ->getName ());
58
+ }
59
+
60
+ public function testCgetWithEntityFilter ()
61
+ {
62
+ $ url = $ this ->getUrl (
63
+ 'orocrm_api_get_channels ' ,
64
+ ['entity ' => 'OroCRM\Bundle\ChannelBundle\Entity\CustomerIdentity ' ]
65
+ );
66
+ $ this ->client ->request ('GET ' , $ url );
67
+
68
+ $ channels = $ this ->getJsonResponseContent ($ this ->client ->getResponse (), 200 );
69
+
26
70
$ this ->assertNotEmpty ($ channels );
27
71
$ this ->assertCount (1 , $ channels );
28
72
}
0 commit comments