Skip to content
This repository was archived by the owner on Feb 25, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
parseConfig.php
/nbproject/private/
66 changes: 62 additions & 4 deletions EnhanceTestFramework.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,34 @@ class TextEn
public $LineFile = 'Line {0} in file {1}';
}

class TextFr
{
public $FormatForTestRunTook = 'Le test a prit {0} seconds';
public $FormatForExpectedButWas = '{0} attendu mais finalement fut {1}';
public $FormatForExpectedNotButWas = 'Pas {0} attendu mais finalement fut {1}';
public $FormatForExpectedContainsButWas = 'Présence de {0} attendu mais finalement fut {1}';
public $FormatForExpectedNotContainsButWas = 'Absence de {0} attendu mais finalement fut {1}';
public $EnhanceTestFramework = 'Enhance Test Framework';
public $EnhanceTestFrameworkFull = 'Enhance PHP Framework de Test Unitaire';
public $TestResults = 'Résultats des tests ';
public $Test = 'Test';
public $TestPassed = 'Test Réussi';
public $TestFailed = 'Test Échoué';
public $Passed = 'Réussi';
public $Failed = 'Échoué';
public $ExpectationFailed = 'Les attentes ne furent pas atteintes';
public $Expected = 'Attendu';
public $Called = 'Appelé ';
public $InconclusiveOrNotImplemented = 'non conclusif ou pas implémenté';
public $Times = 'fois';
public $MethodCoverage = 'Couverture des fonctions';
public $Copyright = 'Copyright';
public $ExpectedExceptionNotThrown = 'L\'exception attendu ne fut pas levée';
public $CannotCallVerifyOnStub = 'impossible d\'appeler VerifyExpectations sur la souche';
public $ReturnsOrThrowsNotBoth = 'Vous ne pouvez définire qu\une seul valeur de retour(1 returns() ou 1 throws())';
public $ScenarioWithExpectMismatch = 'Les scenarios doivent être initialisé avec le même nombre d\'appel à "with" et "expect"';
public $LineFile = 'Ligne {0} dans le fichier {1}';
}
class TextDe
{
public $FormatForTestRunTook = 'Fertig nach {0} Sekunden';
Expand Down Expand Up @@ -411,8 +439,36 @@ class TextSp
public $CannotCallVerifyOnStub = 'No se puede llamar VerifyExpectations en un stub';
public $ReturnsOrThrowsNotBoth = 'Debe proporcionar un solo valor de retorno (1 returns() ó 1 throws())';
public $ScenarioWithExpectMismatch = 'Escenario debe ser inicializado con el mismo número de llamadas "with" y "expect" ';
public $LineFile = 'Linha {0} no arquivo {1}';
public $TypeOfVar=" Tipo: ";
public $LineFile = 'Linha {0} no arquivo {1}';
public $TypeOfVar=" Tipo: ";
}

class TextRo{
public $FormatForTestRunTook = 'Testul a durat {0} secunde';
public $FormatForExpectedButWas = 'Se aștepta {0} dar a returnat {1}';
public $FormatForExpectedNotButWas = 'Nu se aștepta {0} dar a returnat {1}';
public $FormatForExpectedContainsButWas = 'Se aștepta sa conțină {0} dar conține {1}';
public $FormatForExpectedNotContainsButWas = 'Nu se aștepta sa conțină {0} dar conține {1}';
public $EnhanceTestFramework = 'Enhance Test Framework';
public $EnhanceTestFrameworkFull = 'Enhance PHP Unit Testing Framework';
public $TestResults = 'Rezultate Teste';
public $Test = 'Test';
public $TestPassed = 'Testul a fost finalizat cu succes.';
public $TestFailed = 'Testul a eșuat.';
public $Passed = 'Succes';
public $Failed = 'Eșuat.';
public $ExpectationFailed = 'Așteptare eșuată';
public $Expected = 'Așteptare';
public $Called = 'Apelat';
public $InconclusiveOrNotImplemented = 'Neconcludent sau neimplementat';
public $Times = 'Ori';
public $MethodCoverage = 'Învăluire metoda';
public $Copyright = 'Drepturi de autor';
public $ExpectedExceptionNotThrown = 'Se aștepta o excepție dar nu a fost afișata';
public $CannotCallVerifyOnStub = 'Nu a putut fi apelata metoda VerifyExpectations pe un stub';
public $ReturnsOrThrowsNotBoth = 'Trebuie sa alegi numai o valoare pentru a fi returnata (1 returns() sau 1 throws())';
public $ScenarioWithExpectMismatch = 'Scenariul trebuie inițializat cu același număr de apelări la metoda "with" sau "expect" ';
public $LineFile = 'Linia {0} in fișierul {1}';
}

class EnhanceTestFramework
Expand Down Expand Up @@ -1730,14 +1786,16 @@ class TemplateType

class Language
{
const French = "Fr";
const English = 'En';
const Deutsch = 'De';
const BrazilianPortuguese = 'PtBr';
const Spanish = 'Sp';
const Spanish = 'Sp';
const Romana = 'Ro';
}

class Localisation
{
public $Language = Language::English;
}
?>
?>
16 changes: 11 additions & 5 deletions parse.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
include 'parseConfig.php';
include 'parseObject.php';
include 'parseQuery.php';
include 'parseUser.php';
include 'parseFile.php';
include 'parsePush.php';
include 'parseGeoPoint.php';
include 'parseACL.php';
include 'parseRole.php';
include 'parseCloud.php';

class parseRestClient{

private $_appid = '';
private $_masterkey = '';
private $_restkey = '';
Expand All @@ -23,9 +23,9 @@ class parseRestClient{
public function __construct(){
$parseConfig = new parseConfig;
$this->_appid = $parseConfig::APPID;
$this->_masterkey = $parseConfig::MASTERKEY;
$this->_restkey = $parseConfig::RESTKEY;
$this->_parseurl = $parseConfig::PARSEURL;
$this->_masterkey = $parseConfig::MASTERKEY;
$this->_restkey = $parseConfig::RESTKEY;
$this->_parseurl = $parseConfig::PARSEURL;

if(empty($this->_appid) || empty($this->_restkey) || empty($this->_masterkey)){
$this->throwError('You must set your Application ID, Master Key and REST API Key');
Expand Down Expand Up @@ -144,6 +144,12 @@ public function dataType($type,$params){
"objectId" => $params[1]
);
break;
case 'relatedTo':
$return = array(
"object" => $params[0], // pointer
"key" => $params[1] // key
);
break;
case 'geopoint':
$return = array(
"__type" => "GeoPoint",
Expand Down
13 changes: 6 additions & 7 deletions parseACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$acl->setReadAccessForId('user_id',true);
$acl->setWriteAccessForRole('role_name',true);

$object->ACL($acl);
$object->ACL($acl->acl);
$object->save();
*/
class parseACL{
Expand All @@ -20,14 +20,13 @@ public function __construct(){
}
private function setAccessForKey($access,$key,$bool){
if(!($access == 'read' || $access == 'write')) return;
if(is_object($this->acl)) $this->acl = array();
if($bool) $this->acl[$key][$access] = true;
if($bool) $this->acl->$key->$access = true;
else {
if(isset($this->acl[$key])){
unset($this->acl[$key][$access]);
if(sizeof($this->acl[$key]) == 0) unset($this->acl[$key]);
if(isset($this->acl->$key)){
unset($this->acl->$key->$access);
if(sizeof((array)$this->acl->$key) == 0) unset($this->acl->$key);
}
if(sizeof($this->acl) == 0) $this->acl = new stdClass();
if(sizeof((array)$this->acl) == 0) $this->acl = new stdClass();
}
}
public function setPublicReadAccess($bool){
Expand Down
25 changes: 23 additions & 2 deletions parseObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class parseObject extends parseRestClient{
public $_includes = array();
private $_className = '';
protected $_className = '';

public function __construct($class=''){
if($class != ''){
Expand All @@ -21,6 +21,27 @@ public function __set($name,$value){
}
}

public function setClassName($className) {
$this->_className = $className;
}

public function ACL($acl = null) {
if($acl)
$this->data['ACL'] = $acl;

return $this->data['ACL'];
}

public function setProperty($name, $value) {
if($name != '_className'){
$this->data[$name] = $value;
}
}

public function getProperty($name) {
return $this->data[$name];
}

public function save(){
if(count($this->data) > 0 && $this->_className != ''){
$request = $this->request(array(
Expand Down Expand Up @@ -78,7 +99,7 @@ public function delete($id){
return $request;
}
}

public function addInclude($name){
$this->_includes[] = $name;
}
Expand Down
51 changes: 48 additions & 3 deletions parseQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class parseQuery extends parseRestClient{
private $_include = array();

public function __construct($class=''){
if($class == 'users' || $class == 'installation'){
if($class == 'users' || $class == 'roles' || $class == 'installation'){
$this->_requestUrl = $class;
}
elseif($class != ''){
Expand All @@ -31,7 +31,6 @@ public function find(){
));

return $request;

}
else{
$urlParams = array(
Expand Down Expand Up @@ -62,6 +61,7 @@ public function find(){
return $request;
}
}

//setting this to 1 by default since you'd typically only call this function if you were wanting to turn it on
public function setCount($bool=1){
if(is_bool($bool)){
Expand Down Expand Up @@ -161,6 +161,30 @@ public function whereGreaterThan($key,$value){

}

public function whereGreaterThanDate($key,$date){
if(isset($key) && isset($date)){
$this->_query[$key] = array(
'$gt' => $this->dataType('date', $date)
);
}
else{
$this->throwError('the $key and $value parameters must be set when setting a "where" query method');
}

}

public function whereLessThanDate($key,$date){
if(isset($key) && isset($date)){
$this->_query[$key] = array(
'$lt' => $this->dataType('date', $date)
);
}
else{
$this->throwError('the $key and $value parameters must be set when setting a "where" query method');
}

}

public function whereLessThan($key,$value){
if(isset($key) && isset($value)){
$this->_query[$key] = array(
Expand Down Expand Up @@ -290,7 +314,28 @@ public function wherePointer($key,$className,$objectId){
}

}


/**
* Example - to find users with a particular role id
* $query->whereRelatedTo('users', '_Role', $roleId);
*
* @param type $key
* @param type $className
* @param type $objectId
*/
public function whereRelatedTo($key,$className,$objectId) {
if(isset($key) && isset($className) && isset($objectId)){
if($className === 'Role')
$className = '_Role';
if($className === 'User')
$className = '_User';
$pointer = $this->dataType('pointer', array($className, $objectId));
$this->_query['$relatedTo'] = $this->dataType('relatedTo', array($pointer, $key));
} else {
$this->throwError('the $key and $classname and $objectId parameters must be set when setting a "whereRelatedTo" query method');
}
}

public function whereInQuery($key,$className,$inQuery){
if(isset($key) && isset($className)){
$this->_query[$key] = array(
Expand Down
Loading