-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version after module separation
- Loading branch information
hadi
committed
Nov 2, 2017
1 parent
86d784d
commit ad11065
Showing
13 changed files
with
1,110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Eclipse | ||
.project | ||
.settings | ||
/.buildpath | ||
|
||
# Composer | ||
/vendor/ | ||
composer.lock | ||
composer-setup.php | ||
composer.phar | ||
|
||
# Project | ||
storage/tenant | ||
|
||
# KDE | ||
.directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
language: php | ||
php: | ||
- '5.6' | ||
|
||
mysql: | ||
database: test | ||
username: root | ||
encoding: utf8 | ||
|
||
before_install: | ||
- sudo apt-get update > /dev/null | ||
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
- php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | ||
- php composer-setup.php | ||
- php -r "unlink('composer-setup.php');" | ||
|
||
install: | ||
- php composer.phar install | ||
|
||
script: | ||
- cd tests | ||
- php run.php | ||
- php coverage-checker.php clover.xml 70 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name" : "pluf/tenant", | ||
"description" : "A pluf module to manage current tenant", | ||
"type" : "library", | ||
"license" : "MIT", | ||
"authors" : [{ | ||
"name" : "Mostafa Barmshory", | ||
"email" : "[email protected]", | ||
"homepage" : "http://dpq.co.ir", | ||
"role" : "developer" | ||
}, { | ||
"name" : "Mohammad Hadi Mansouri", | ||
"email" : "[email protected]", | ||
"homepage" : "http://dpq.co.ir", | ||
"role" : "developer" | ||
} | ||
], | ||
"minimum-stability" : "stable", | ||
"require" : { | ||
"pluf/core" : "^2.1.0", | ||
"pluf/user" : "^2.1.0" | ||
}, | ||
"require-dev" : { | ||
"phpunit/phpunit" : "^5.7.14", | ||
"phpunit/php-invoker" : "^1.1", | ||
"phpunit/dbunit" : "^2.0", | ||
"phpunit/phpunit-story" : "^1.0" | ||
}, | ||
"include-path" : [ | ||
"src/" | ||
], | ||
"homepage" : "https://github.com/pluf/tenant", | ||
"support" : { | ||
"email" : "[email protected]", | ||
"issues" : "https://github.com/pluf/tenant/issues", | ||
"forum" : "https://github.com/pluf/tenant", | ||
"wiki" : "https://github.com/pluf/tenant/wiki", | ||
"source" : "https://github.com/pluf/tenant" | ||
}, | ||
"keywords" : [ | ||
"pluf", | ||
"php", | ||
"pluf-module", | ||
"tenant" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Pluf Framework, a simple PHP Application Framework. | ||
* Copyright (C) 2010-2020 Phoinex Scholars Co. (http://dpq.co.ir) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
class Tenant_Monitor | ||
{ | ||
|
||
public static function count () | ||
{ | ||
// XXX: maso, 1395 | ||
} | ||
|
||
public static function storage () | ||
{ | ||
$result = array( | ||
'value' => 35, | ||
'min' => 0, | ||
'max' => Config_Service::get('storage.size.max', 10485760), // 10Mb | ||
'unit' => 'byte', | ||
'interval' => 1000000, | ||
'type' => 'scalar' | ||
); | ||
// maso, 2017: find storage size | ||
// FIXME: maso, 2017: using php native if is not linux | ||
$file_directory = Pluf_Tenant::storagePath(); | ||
// $output = exec('du -sk ' . $file_directory); | ||
// $result['value'] = trim(str_replace($file_directory, '', $output)) * 1024; | ||
$result['value'] = Pluf_Shortcuts_folderSize($file_directory); | ||
return $result; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/* | ||
* This file is part of Pluf Framework, a simple PHP Application Framework. | ||
* Copyright (C) 2010-2020 Phoinex Scholars Co. (http://dpq.co.ir) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
Pluf::loadFunction('Pluf_Shortcuts_GetObjectOr404'); | ||
Pluf::loadFunction('Pluf_Shortcuts_GetFormForModel'); | ||
|
||
/** | ||
* لایه نمایش مدیریت گروهها را به صورت پیش فرض ایجاد میکند | ||
* | ||
* @author maso | ||
* | ||
*/ | ||
class Tenant_Views extends Pluf_Views | ||
{ | ||
|
||
/** | ||
* | ||
* @param unknown_type $request | ||
* @param unknown_type $match | ||
*/ | ||
public static function current ($request, $match) | ||
{ | ||
return new Pluf_HTTP_Response_Json($request->tenant); | ||
} | ||
|
||
/** | ||
* | ||
* @param unknown_type $request | ||
* @param unknown_type $match | ||
*/ | ||
public static function update ($request, $match) | ||
{ | ||
$model = $request->tenant; | ||
$form = Pluf_Shortcuts_GetFormForModel($model, $request->REQUEST, | ||
array()); | ||
return new Pluf_HTTP_Response_Json($form->save()); | ||
} | ||
|
||
/** | ||
* | ||
* @param unknown_type $request | ||
* @param unknown_type $match | ||
*/ | ||
public static function get ($request, $match) | ||
{ | ||
return Tenant_Views::current($request, $match); | ||
} | ||
|
||
/** | ||
* | ||
* @param unknown_type $request | ||
* @param unknown_type $match | ||
*/ | ||
public function delete ($request, $match) | ||
{ | ||
$model = $request->tenant; | ||
$model2 = Pluf_Shortcuts_GetObjectOr404('Pluf_Tenant', $request->tenant->id); | ||
$model2->delete(); | ||
// XXX: maso, 1395: delete permisions | ||
// XXX: maso, 1395: delete files | ||
// XXX: maso, 1395: delete Settings, configs | ||
// XXX: maso, 1395: emite signal | ||
return new Pluf_HTTP_Response_Json($model); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "Tenant", | ||
"version": "2.1.9", | ||
"title": "Tenant Management", | ||
"permisson": [], | ||
"monitor":[{ | ||
"bean": "tenant", | ||
"property": "storage", | ||
"title": "Storage size", | ||
"description": "Storage size of the tenant.", | ||
"function": "Tenant_Monitor::Storage", | ||
"level": 1 | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/* | ||
* This file is part of Pluf Framework, a simple PHP Application Framework. | ||
* Copyright (C) 2010-2020 Phoinex Scholars Co. (http://dpq.co.ir) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
return array (); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
/* | ||
* This file is part of Pluf Framework, a simple PHP Application Framework. | ||
* Copyright (C) 2010-2020 Phoinex Scholars Co. (http://dpq.co.ir) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
return array( | ||
array( | ||
'regex' => '#^$#', | ||
'model' => 'Tenant_Views', | ||
'method' => 'current', | ||
'http-method' => 'GET', | ||
'precond' => array() | ||
), | ||
array( | ||
'regex' => '#^$#', | ||
'model' => 'Tenant_Views', | ||
'method' => 'update', | ||
'http-method' => 'POST', | ||
'precond' => array( | ||
'Pluf_Precondition::ownerRequired' | ||
) | ||
), | ||
array( | ||
'regex' => '#^$#', | ||
'model' => 'Tenant_Views', | ||
'method' => 'delete', | ||
'http-method' => 'DELETE', | ||
'precond' => array( | ||
'Pluf_Precondition::ownerRequired' | ||
) | ||
) | ||
// array( | ||
// 'regex' => '#^/find$#', | ||
// 'model' => 'Tenant_Views', | ||
// 'method' => 'find', | ||
// 'http-method' => 'GET', | ||
// 'precond' => array( | ||
// 'Pluf_Precondition::loginRequired' | ||
// ) | ||
// ), | ||
// array( | ||
// 'regex' => '#^/new$#', | ||
// 'model' => 'Tenant_Views', | ||
// 'method' => 'create', | ||
// 'http-method' => 'POST', | ||
// 'precond' => array( | ||
// 'Pluf_Precondition::loginRequired' | ||
// ) | ||
// ), | ||
// array( | ||
// 'regex' => '#^/(?P<id>.+)$#', | ||
// 'model' => 'Tenant_Views', | ||
// 'method' => 'get', | ||
// 'http-method' => 'GET', | ||
// 'precond' => array( | ||
// 'Pluf_Precondition::loginRequired' | ||
// ) | ||
// ), | ||
// array( | ||
// 'regex' => '#^/(?P<id>.+)$#', | ||
// 'model' => 'Tenant_Views', | ||
// 'method' => 'update', | ||
// 'http-method' => 'POST', | ||
// 'precond' => array( | ||
// 'Pluf_Precondition::loginRequired' | ||
// ) | ||
// ), | ||
// array( | ||
// 'regex' => '#^/(?P<id>.+)$#', | ||
// 'model' => 'Tenant_Views', | ||
// 'method' => 'delete', | ||
// 'http-method' => 'DELETE', | ||
// 'precond' => array( | ||
// 'Pluf_Precondition::loginRequired' | ||
// ) | ||
// ) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/clover.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
// coverage-checker.php | ||
$inputFile = $argv[1]; | ||
$percentage = min(100, max(0, (int) $argv[2])); | ||
|
||
if (!file_exists($inputFile)) { | ||
throw new InvalidArgumentException('Invalid input file provided'); | ||
} | ||
|
||
if (!$percentage) { | ||
throw new InvalidArgumentException('An integer checked percentage must be given as second parameter'); | ||
} | ||
|
||
$xml = new SimpleXMLElement(file_get_contents($inputFile)); | ||
$metrics = $xml->xpath('//metrics'); | ||
$totalElements = 0; | ||
$checkedElements = 0; | ||
|
||
foreach ($metrics as $metric) { | ||
$totalElements += (int) $metric['elements']; | ||
$checkedElements += (int) $metric['coveredelements']; | ||
} | ||
|
||
$coverage = ($checkedElements / $totalElements) * 100; | ||
|
||
if ($coverage < $percentage) { | ||
echo 'Code coverage is ' . $coverage . '%, which is below the accepted ' . $percentage . '%' . PHP_EOL; | ||
exit(1); | ||
} | ||
|
||
echo 'Code coverage is ' . $coverage . '% - OK!' . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit colors="true"> | ||
<testsuites> | ||
<testsuite name="pluf/tenant"> | ||
<directory>./Tenant_Api/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
Oops, something went wrong.