File tree Expand file tree Collapse file tree 3 files changed +107
-0
lines changed
Expand file tree Collapse file tree 3 files changed +107
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "id" : " APP_SESSION_ID" ,
3+ "installationId" : " INSTALLATION_ID" ,
4+ "merchantAccount" : " YOUR_MERCHANT_ACCOUNT" ,
5+ "store" : " YOUR_STORE_ID" ,
6+ "sdkData" : " SDK_DATA_BLOB"
7+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Adyen \Tests \Unit ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use Adyen \Client ;
7+ use Adyen \Environment ;
8+
9+ class ClientTest extends TestCase
10+ {
11+
12+ public function testCreate (): void
13+ {
14+ $ client = new Client ();
15+ $ client ->setApplicationName ("My Test Application " );
16+ $ client ->setEnvironment (Environment::TEST );
17+ $ client ->setXApiKey ("MockAPIKey " );
18+ $ client ->setTimeout (60 );
19+ $ client ->setConnectionTimeout (30 );
20+
21+ $ this ->assertEquals (
22+ "test " ,
23+ $ client ->getConfig ()->getEnvironment ()
24+ );
25+ }
26+
27+ public function testCreateWithLivePrefix (): void
28+ {
29+ $ client = new Client ();
30+ $ client ->setEnvironment (Environment::LIVE );
31+ $ client ->setXApiKey ("MockAPIKey " );
32+
33+ // check LIVE Terminal API url
34+ $ this ->assertEquals (
35+ "https://terminal-api-live.adyen.com " ,
36+ $ client ->getConfig ()->get ('endpointTerminalCloud ' )
37+ );
38+
39+ }
40+
41+ public function testCreateWithInvalidPrefix (): void
42+ {
43+ // check an exception is thrown
44+ $ this ->expectException (\Adyen \AdyenException::class);
45+
46+ $ client = new Client ();
47+ $ client ->setEnvironment ("Invalid " );
48+ $ client ->setXApiKey ("MockAPIKey " );
49+ }
50+
51+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Adyen \Tests \Unit ;
4+
5+ use Adyen \Service \PosMobileApi ;
6+ use Adyen \Model \PosMobile \CreateSessionRequest ;
7+ use Adyen \Environment ;
8+
9+ class PosMobileApiTest extends TestCaseMock
10+ {
11+
12+ /**
13+ * @param $jsonFile
14+ * @param $httpStatus
15+ * @dataProvider posMobileApiProvider
16+ * @throws \Adyen\AdyenException
17+ */
18+ public function testCreateCommunicationSessionSuccess ($ jsonFile , $ httpStatus ): void
19+ {
20+ // create client
21+ $ client = $ this ->createMockClient ($ jsonFile , $ httpStatus , $ environment = Environment::LIVE );
22+
23+
24+ // initialize service
25+ $ service = new PosMobileApi ($ client );
26+
27+ $ json = '{
28+ "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
29+ "setupToken": "SETUP_TOKEN",
30+ "store": "YOUR_STORE_ID"
31+ } ' ;
32+
33+ //$params = json_decode($json, true);
34+ $ params = new CreateSessionRequest (json_decode ($ json , true ));
35+
36+ $ result = $ service ->createCommunicationSession ($ params );
37+
38+ $ this ->assertEquals ('APP_SESSION_ID ' , $ result ->getId ());
39+ }
40+
41+
42+ public static function posMobileApiProvider ()
43+ {
44+ return array (
45+ array ('tests/Resources/PosMobileApp/create-auth-session.json ' , 200 ),
46+ );
47+ }
48+
49+ }
You can’t perform that action at this time.
0 commit comments