Skip to content

Commit 7212c0c

Browse files
author
Fosco Marotto
committed
Added ParseSession
1 parent 0171095 commit 7212c0c

File tree

4 files changed

+49
-54
lines changed

4 files changed

+49
-54
lines changed

tests/IncrementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function testIncrementEmptyFieldAndTypeConflict()
211211
$obj->save();
212212
$objAgain->increment('randomkey');
213213
$this->setExpectedException('Parse\ParseException',
214-
"can't increment a field that isn't a number"
214+
"invalid type for key"
215215
);
216216
$objAgain->save();
217217
}

tests/ParseCloudTest.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -31,63 +31,11 @@ public function testFunctionsWithGeoPointParamsDoNotThrow()
3131
ParseCloud::run('unknown_function', $params);
3232
}
3333

34-
public function testExplicitFunctionFailure()
35-
{
36-
$params = array('key1' => 'value1');
37-
$this->setExpectedException('Parse\ParseException','bad stuff happened');
38-
ParseCloud::run('bar', $params);
39-
}
40-
4134
public function testUnknownFunctionFailure()
4235
{
4336
$params = array('key1' => 'value1');
4437
$this->setExpectedException('Parse\ParseException','function not found');
4538
ParseCloud::run('unknown_function', $params);
4639
}
4740

48-
public function testFunctions()
49-
{
50-
$params = array(
51-
'key1' => 'value1',
52-
'key2' => array(1,2,3)
53-
);
54-
$response = ParseCloud::run('foo', $params);
55-
$obj = $response['object'];
56-
$this->assertTrue($obj instanceof ParseObject);
57-
$this->assertEquals('Foo', $obj->className);
58-
$this->assertEquals(2, $obj->get('x'));
59-
$relation = $obj->get('relation');
60-
$this->assertTrue($relation instanceof ParseObject);
61-
$this->assertEquals('Bar', $relation->className);
62-
$this->assertEquals(3, $relation->get('x'));
63-
$obj = $response['array'][0];
64-
$this->assertTrue($obj instanceof ParseObject);
65-
$this->assertEquals('Bar', $obj->className);
66-
$this->assertEquals(2, $obj->get('x'));
67-
68-
$response = ParseCloud::run('foo', array('key1' => 'value1'));
69-
$this->assertEquals(2, $response['a']);
70-
71-
try {
72-
$response = ParseCloud::run('bar', array('key1' => 'value1'));
73-
$this->fail('Should have thrown an exception.');
74-
} catch(Parse\ParseException $ex) {
75-
// A parse exception should occur.
76-
}
77-
78-
$response = ParseCloud::run('bar', array('key2' => 'value1'));
79-
$this->assertEquals('Foo', $response);
80-
81-
$obj = ParseObject::create('SomeClass');
82-
$obj->set('name', 'Zanzibar');
83-
$obj->save();
84-
85-
$params = array('key2' => 'value1', 'key1' => $obj);
86-
try {
87-
$response = ParseCloud::run('foo', $params);
88-
$this->fail('Should have thrown an exception.');
89-
} catch (\Exception $ex) {
90-
// An exception should occur.
91-
}
92-
}
9341
}

tests/ParseObjectTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function testCanSetBoolean()
271271
public function testInvalidClassName()
272272
{
273273
$obj = ParseObject::create('Foo^bar');
274-
$this->setExpectedException('Parse\ParseException', 'Bad Request');
274+
$this->setExpectedException('Parse\ParseException', 'bad characters in classname');
275275
$obj->save();
276276
}
277277

tests/ParseSessionTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
use Parse\ParseClient;
4+
use Parse\ParseObject;
5+
use Parse\ParseQuery;
6+
use Parse\ParseUser;
7+
use Parse\ParseSession;
8+
9+
require_once 'ParseTestHelper.php';
10+
11+
class ParseSessionTest extends PHPUnit_Framework_TestCase
12+
{
13+
14+
public static function setUpBeforeClass()
15+
{
16+
ParseTestHelper::setUp();
17+
ParseTestHelper::clearClass(ParseUser::$parseClassName);
18+
ParseTestHelper::clearClass(ParseSession::$parseClassName);
19+
}
20+
21+
public function tearDown()
22+
{
23+
ParseTestHelper::tearDown();
24+
ParseUser::logOut();
25+
ParseTestHelper::clearClass(ParseUser::$parseClassName);
26+
ParseTestHelper::clearClass(ParseSession::$parseClassName);
27+
}
28+
29+
public static function tearDownAfterClass()
30+
{
31+
ParseUser::_unregisterSubclass();
32+
ParseSession::_unregisterSubclass();
33+
}
34+
35+
public function testGetCurrentSession()
36+
{
37+
ParseClient::enableRevocableSessions();
38+
$user = new ParseUser();
39+
$user->setUsername("username");
40+
$user->setPassword("password");
41+
$user->signUp();
42+
$session = ParseSession::getCurrentSession();
43+
$this->assertEquals($user->getSessionToken(), $session->getSessionToken());
44+
$this->assertTrue($session->isCurrentSessionRevocable());
45+
}
46+
47+
}

0 commit comments

Comments
 (0)