Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
Reo Mori committed Jun 24, 2011
0 parents commit 416769e
Show file tree
Hide file tree
Showing 594 changed files with 56,230 additions and 0 deletions.
48 changes: 48 additions & 0 deletions LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-------------------------------------------------------------------------------

Sabel 1.2 Beta2 - Rapid Web Application Development Framework

The New BSD License

Copyright (c) 2004-2009
Mori Reo <[email protected]> All rights reserved.

-------------------------------------------------------------------------------

Authors:

Mori Reo <[email protected]>
Ebine Yutaka <[email protected]>
Hamanaka Kazuhiro <[email protected]>
Hosokawa Yasuko <[email protected]>

-------------------------------------------------------------------------------

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

-------------------------------------------------------------------------------

For more information on the Sabel project,
please see <http://sabel.php-framework.org/>

-------------------------------------------------------------------------------
204 changes: 204 additions & 0 deletions Sabel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<?php

/**
* Sabel
*
* @category Core
* @package org.sabel.core
* @author Mori Reo <[email protected]>
* @author Ebine Yutaka <[email protected]>
* @copyright 2004-2008 Mori Reo <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
final class Sabel
{
/**
* @var array
*/
private static $readableFiles = array();

/**
* @var int
*/
private static $readableFilesNum = 0;

/**
* @var array
*/
private static $required = array();

/**
* @var array
*/
private static $fileUsing = array();

public static function getPath()
{
return dirname(__FILE__);
}

public static function using($className)
{
if (class_exists($className, false)) {
return true;
} else {
return self::autoload($className);
}
}

public static function autoload($className)
{
if (isset(self::$required[$className])) return true;

if (isset(self::$readableFiles[$className])) {
require (self::$readableFiles[$className]);
self::$required[$className] = 1;
return true;
} elseif ($path = self::getFilePath($className)) {
require ($path);

self::$required[$className] = 1;
self::$readableFiles[$className] = $path;
return true;
} else {
return false;
}
}

public static function fileUsing($path, $once = false)
{
if ($once && isset(self::$fileUsing[$path])) return true;

if (isset(self::$readableFiles[$path])) {
$readable = true;
} elseif (is_readable($path)) {
$readable = true;
self::$readableFiles[$path] = $path;
} else {
$readable = false;
}

if ($readable) {
($once) ? require_once ($path) : require ($path);
self::$fileUsing[$path] = 1;
return true;
}

return false;
}

private static function getFilePath($className)
{
static $includePath = null;
static $paths = null;

$exp = explode("_", $className);

if (count($exp) === 1) {
$path = $exp[0] . ".php";
} else {
$class = array_pop($exp);
$prePath = implode("/", array_map("lcfirst", $exp));
$path = $prePath . DIRECTORY_SEPARATOR . $class . ".php";
}

if ($includePath === null) {
$includePath = get_include_path();
} elseif (($incPath = get_include_path()) !== $includePath) {
$includePath = $incPath;
$paths = null;
}

if ($paths === null) {
$paths = explode(PATH_SEPARATOR, $includePath);
}

foreach ($paths as $p) {
$fullPath = $p . DIRECTORY_SEPARATOR . $path;
if (is_readable($fullPath)) return $fullPath;
}

return false;
}

public static function main()
{
$SABEL = "sabel" . DIRECTORY_SEPARATOR;

require ($SABEL . "Object.php");
require ($SABEL . "Logger.php");
require ($SABEL . "Bus.php");
require ($SABEL . "Config.php");
require ($SABEL . "Context.php");
require ($SABEL . "Request.php");
require ($SABEL . "Session.php");
require ($SABEL . "Response.php");
require ($SABEL . "View.php");

require ($SABEL . "functions" . DIRECTORY_SEPARATOR . "core.php");
require ($SABEL . "functions" . DIRECTORY_SEPARATOR . "db.php");

$BUS = $SABEL . "bus" . DIRECTORY_SEPARATOR;
$MAP = $SABEL . "map" . DIRECTORY_SEPARATOR;
$CTRL = $SABEL . "controller" . DIRECTORY_SEPARATOR;
$RESP = $SABEL . "response" . DIRECTORY_SEPARATOR;
$SESSION = $SABEL . "session" . DIRECTORY_SEPARATOR;
$VIEW = $SABEL . "view" . DIRECTORY_SEPARATOR;
$UTIL = $SABEL . "util" . DIRECTORY_SEPARATOR;

require ($BUS . "Config.php");
require ($BUS . "Processor.php");

require ($MAP . "Configurator.php");
require ($MAP . "Candidate.php");
require ($MAP . "Destination.php");
require ($MAP . "config" . DIRECTORY_SEPARATOR . "Route.php");

require ($RESP . "Object.php");
require ($RESP . "Status.php");
require ($RESP . "Redirector.php");
require ($RESP . "Header.php");

require ($SESSION . "Abstract.php");
require ($SESSION . "PHP.php");

require ($VIEW . "Renderer.php");
require ($VIEW . "Object.php");
require ($VIEW . "Location.php");
require ($VIEW . "location" . DIRECTORY_SEPARATOR . "File.php");

require ($UTIL . "HashList.php");
require ($UTIL . "VariableCache.php");

require ($SABEL . "request" . DIRECTORY_SEPARATOR . "Object.php");
require ($SABEL . "controller" . DIRECTORY_SEPARATOR . "Page.php");
require ($SABEL . "exception" . DIRECTORY_SEPARATOR . "Runtime.php");
require ($SABEL . "logger" . DIRECTORY_SEPARATOR . "Interface.php");
}

public static function init()
{
$path = "sabel" . DIRECTORY_SEPARATOR . "Sabel";
$cache = Sabel_Util_VariableCache::create($path);

if ($files = $cache->read("readableFiles")) {
self::$readableFiles = $files;
self::$readableFilesNum = count($files);
}
}

public static function shutdown()
{
if (self::$readableFilesNum !== count(self::$readableFiles)) {
$path = "sabel" . DIRECTORY_SEPARATOR . "Sabel";
$cache = Sabel_Util_VariableCache::create($path);
$cache->write("readableFiles", self::$readableFiles);
$cache->save();
}
}
}

/* register autoload method */
spl_autoload_register(array("Sabel", "autoload"));

Sabel::main();
139 changes: 139 additions & 0 deletions SabelAllTests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php

define("TEST_CASE", true);
define("SABEL_BASE", dirname(realpath(__FILE__)));
define("DS", DIRECTORY_SEPARATOR);

define("SBL_LOG_INFO", 0x01);
define("SBL_LOG_DEBUG", 0x02);
define("SBL_LOG_WARN", 0x04);
define("SBL_LOG_ERR", 0x08);
define("SBL_LOG_ALL", 0xFF);
define("SBL_LOG_LEVEL", SBL_LOG_ALL);

if (in_array("-db", $_SERVER["argv"], true)) {
PHPUnit_Util_Filter::addDirectoryToWhitelist(SABEL_BASE . DS . "sabel" . DS . "db");
} else {
PHPUnit_Util_Filter::addDirectoryToWhitelist(SABEL_BASE . DS . "sabel");
PHPUnit_Util_Filter::removeFileFromWhitelist(SABEL_BASE . DS . "sabel" . DS . "Sakle.php");
PHPUnit_Util_Filter::removeDirectoryFromWhitelist(SABEL_BASE . DS . "sabel" . DS . "db");
PHPUnit_Util_Filter::removeDirectoryFromWhitelist(SABEL_BASE . DS . "sabel" . DS . "sakle");
PHPUnit_Util_Filter::removeDirectoryFromWhitelist(SABEL_BASE . DS . "sabel" . DS . "test");
PHPUnit_Util_Filter::removeDirectoryFromWhitelist(SABEL_BASE . DS . "sabel" . DS . "cookie");
PHPUnit_Util_Filter::removeFileFromWhitelist(SABEL_BASE . DS . "sabel" . DS . "response" . DS . "Header.php");
}

define("TEST_DATA_DIR", SABEL_BASE . DS . "Test" . DS . "data");
define("TEST_APP_DIR", TEST_DATA_DIR . DS . "application");
define("MODULES_DIR_NAME", "app");
define("VIEW_DIR_NAME", "views");
define("LOG_DIR_PATH", TEST_APP_DIR . DS . "logs");
define("MODULES_DIR_PATH", TEST_APP_DIR . DS . "app");
define("COMPILE_DIR_PATH", TEST_APP_DIR . DS . "data" . DS . "compiled");

define("PRODUCTION", 0x01);
define("TEST", 0x02);
define("DEVELOPMENT", 0x04);
define("ENVIRONMENT", TEST);
define("TPL_SUFFIX", ".tpl");
define("SBL_SECURE_MODE", true);

if (!defined("PHPUnit_MAIN_METHOD")) {
define("PHPUnit_MAIN_METHOD", "SabelAllTests::main");
}

error_reporting(E_ALL|E_STRICT);

require_once ("PHPUnit/Framework/Test.php");
require_once ("PHPUnit/Framework/Warning.php");
require_once ("PHPUnit/TextUI/TestRunner.php");
require_once ("PHPUnit/Framework/TestCase.php");
require_once ("PHPUnit/Framework/TestSuite.php");
require_once ("PHPUnit/Framework/IncompleteTestError.php");

require_once ("Sabel.php");

require_once ("Test/SabelTestCase.php");

require_once ("Test/Application.php");
require_once ("Test/Object.php");
require_once ("Test/ValueObject.php");
require_once ("Test/Console.php");

require_once ("Test/Annotation.php");
//require_once ("Test/Aspect/Tests.php");
require_once ("Test/Container.php");

require_once ("Test/Exception.php");
require_once ("Test/Bus/Tests.php");
require_once ("Test/Request/Tests.php");
require_once ("Test/Response/Tests.php");
require_once ("Test/Controller/Tests.php");
require_once ("Test/Util/Tests.php");
require_once ("Test/View/Tests.php");
require_once ("Test/Map/Tests.php");
require_once ("Test/Processor/Tests.php");

require_once ("Test/Reflection.php");

require_once ("Test/Cache/Tests.php");
require_once ("Test/Mail/Tests.php");
require_once ("Test/Session/Tests.php");
require_once ("Test/VirtualInheritance.php");
require_once ("Test/DB/TestConfig.php");
require_once ("Test/DB/Statement/Tests.php");
require_once ("Test/DB/Storage/Tests.php");
require_once ("Test/DB/Tests.php");
require_once ("Test/XML/Tests.php");
require_once ("Test/I18n/Gettext.php");
require_once ("Test/Cookie/Tests.php");


class SabelAllTests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}

public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite();

if (in_array("-db", $_SERVER["argv"], true)) {
$suite->addTest(Test_DB_Statement_Tests::suite());
$suite->addTest(Test_DB_Storage_Tests::suite());
$suite->addTest(Test_DB_Tests::suite());
return $suite;
}

$suite->addTest(Test_Object::suite());
$suite->addTest(Test_ValueObject::suite());
$suite->addTest(Test_Console::suite());
$suite->addTest(Test_Bus_Tests::suite());
$suite->addTest(Test_Map_Tests::suite());
$suite->addTest(Test_Request_Tests::suite());
$suite->addTest(Test_Response_Tests::suite());
$suite->addTest(Test_Controller_Tests::suite());
$suite->addTest(Test_Util_Tests::suite());
$suite->addTest(Test_View_Tests::suite());
$suite->addTest(Test_Cache_Tests::suite());
$suite->addTest(Test_Session_Tests::suite());
$suite->addTest(Test_Processor_Tests::suite());

$suite->addTest(Test_Annotation::suite());
$suite->addTest(Test_Reflection::suite());
$suite->addTest(Test_Container::suite());
//$suite->addTest(Test_Aspect_Tests::suite());
$suite->addTest(Test_Exception::suite());

$suite->addTest(Test_I18n_Gettext::suite());
$suite->addTest(Test_Cookie_Tests::suite());
$suite->addTest(Test_Mail_Tests::suite());
$suite->addTest(Test_XML_Tests::suite());

$suite->addTest(Test_Application::suite());

return $suite;
}
}
Loading

0 comments on commit 416769e

Please sign in to comment.