forked from parse-community/parse-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParseAppTest.php
More file actions
106 lines (84 loc) · 3.01 KB
/
Copy pathParseAppTest.php
File metadata and controls
106 lines (84 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
namespace Parse\Test;
use Parse\ParseApp;
use PHPUnit_Framework_TestCase;
class ParseAppTest extends PHPUnit_Framework_TestCase
{
public static function setUpBeforeClass()
{
Helper::setUp();
}
public function testFetchingApps()
{
self::_createApp(self::_getNewName());
self::_createApp(self::_getNewName());
$apps = ParseApp::fetchApps();
$this->assertGreaterThanOrEqual(2, $apps);
}
public function testFetchSingleApp()
{
$app_created = self::_createApp(self::_getNewName());
$app = ParseApp::fetchApp($app_created['applicationId']);
$this->assertCount(13, $app);
}
public function testFetchNotFound()
{
$invalid_application_id = '1YkU7V110nEDUqU7ctCEbLr6xcgQgdEkePuBaw6P';
$this->setExpectedException('Parse\ParseException', 'requested resource was not found');
ParseApp::fetchApp($invalid_application_id);
}
public function testCreateApp()
{
$app_name = self::_getNewName();
$app = ParseApp::createApp([
'appName' => $app_name,
]);
$this->assertEquals($app_name, $app['appName']);
$this->assertEquals(true, $app['clientClassCreationEnabled']);
$this->assertEquals(false, $app['clientPushEnabled']);
$this->assertEquals(true, $app['requireRevocableSessions']);
$this->assertEquals(true, $app['revokeSessionOnPasswordChange']);
}
public function testNameAlreadyInAccount()
{
$app_name = self::_getNewName();
ParseApp::createApp([
'appName' => $app_name,
]);
$this->setExpectedException('Parse\ParseException', 'App name must not already be used in your account');
ParseApp::createApp([
'appName' => $app_name,
]);
}
public function testUpdateApp()
{
$app_name = self::_getNewName();
$updated_name = self::_getNewName();
$this->assertNotEquals($app_name, $updated_name);
$app = ParseApp::createApp([
'appName' => $app_name,
]);
$updated_app = ParseApp::updateApp($app['applicationId'], [
'appName' => $updated_name,
'clientClassCreationEnabled' => false,
'clientPushEnabled' => true,
'requireRevocableSessions' => false,
'revokeSessionOnPasswordChange' => false,
]);
$this->assertEquals($updated_name, $updated_app['appName']);
$this->assertNotTrue($updated_name['clientClassCreationEnabled']);
$this->assertNotFalse($updated_name['clientPushEnabled']);
$this->assertNotTrue($updated_name['requireRevocableSessions']);
$this->assertNotTrue($updated_name['revokeSessionOnPasswordChange']);
}
private static function _createApp($name)
{
return ParseApp::createApp([
'appName' => $name,
]);
}
private static function _getNewName()
{
return md5(uniqid(rand(), true));
}
}