diff --git a/app/Bootstrap.php b/app/Bootstrap.php index 3833103..e10a944 100644 --- a/app/Bootstrap.php +++ b/app/Bootstrap.php @@ -10,7 +10,7 @@ use Dframe\Session; use Dframe\Messages; use Dframe\Token; -use Dframe\Database\Database; + require_once dirname(__DIR__) . '/web/config.php'; @@ -25,26 +25,19 @@ class Bootstrap public function __construct() { - try { - if (!empty(DB_HOST)) { - $dbConfig = array( - 'host' => DB_HOST, - 'dbname' => DB_DATABASE, - 'username' => DB_USER, - 'password' => DB_PASS, - ); - $this->db = new Database($dbConfig); - $this->db->setErrorLog(setErrorLog); // Debugowanie - } - - } catch (DBException $e) { - echo 'The connect can not create: ' . $e->getMessage(); - exit(); - } - - $this->session = new Session('session_name'); // Best to set projectName - $this->msg = new Messages($this->session); // Default notify class - $this->token = new Token($this->session); // Default csrf token + + $this->providers['core'] = [ + 'router' => \Dframe\Router::class, + ]; + + $this->providers['baseClass'] = [ + 'session' => \Dframe\Session::class, // Best to set projec + 'msg' => \Dframe\Messages::class, // Default notify cl + 'token' => \Dframe\Token::class, // Default csrf token + ]; + + $this->providers['modules'] = [ + ]; return $this; } diff --git a/app/Model/Model.php b/app/Model/Model.php index 8ad56a6..8a79a67 100644 --- a/app/Model/Model.php +++ b/app/Model/Model.php @@ -9,6 +9,7 @@ namespace Model; +use Dframe\Database\Database; /** * This class includes methods for models. * @@ -17,5 +18,24 @@ abstract class Model extends \Dframe\Model { + public function start() + { + try { + if (!empty(DB_HOST)) { + $dbConfig = array( + 'host' => DB_HOST, + 'dbname' => DB_DATABASE, + 'username' => DB_USER, + 'password' => DB_PASS, + ); + $this->db = new Database($dbConfig); + $this->db->setErrorLog(setErrorLog); // Debugowanie + } + + } catch (DBException $e) { + echo 'The connect can not create: ' . $e->getMessage(); + exit(); + } + } } diff --git a/app/Tests/RunTest.php b/app/Tests/RunTest.php index 4a19f19..39ac277 100644 --- a/app/Tests/RunTest.php +++ b/app/Tests/RunTest.php @@ -9,15 +9,12 @@ namespace Tests; +use PHPUnit\Framework\TestCase; + ini_set('session.use_cookies', 0); session_start(); -// backward compatibility -if (!class_exists('\PHPUnit\Framework\TestCase') and class_exists('\PHPUnit_Framework_TestCase')) { - class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); -} - $autoloader = include dirname(__DIR__) . '../../vendor/autoload.php'; require_once dirname(__FILE__) . '/../Bootstrap.php'; require_once dirname(__FILE__) . '/../../web/config.php'; @@ -28,7 +25,7 @@ class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase'); * @author SÅ‚awek Kaleta */ -class RunTest extends \PHPUnit\Framework\TestCase +class RunTest extends TestCase { @@ -38,7 +35,7 @@ public function testCreateController() $bootstrap->router = new \Dframe\Router(); $run = new \Dframe\Loader($bootstrap); - $page = $run->loadController('Page'); + $page = $run->loadController('Page')->returnController; $this->assertEquals('{"return":"1"}', $page->json()->getBody()); diff --git a/app/View/View.php b/app/View/View.php index 64c0d58..21ea980 100644 --- a/app/View/View.php +++ b/app/View/View.php @@ -1,4 +1,5 @@ setView(new \Dframe\View\SmartyView()); - parent::__construct($baseClass); + $this->view = new \Dframe\View\SmartyView(); } } \ No newline at end of file diff --git a/composer.json b/composer.json index acbb742..7108c4d 100644 --- a/composer.json +++ b/composer.json @@ -2,21 +2,38 @@ "name": "dframe/dframe-demo", "description": "It is a simple demo website based on Dframeframework", "license": "MIT", - "keywords": ["dframe", "demo", "framework", "website", "application", "blog"], + "keywords": [ + "dframe", + "demo", + "framework", + "website", + "application", + "blog" + ], "homepage": "https://dframeframework.com", "type": "project", "autoload": { - "psr-4": {"": "app/"} + "psr-4": { + "": "app/" + } }, "require": { - "dframe/dframe": "dev-master", + "dframe/dframe": "dev-beta-modular", "dframe/database": "^1.3", "smarty/smarty": "^3.1" }, + "autoload-dev": { + "psr-4": { + "Dframe\\tests\\": "tests" + } + }, + "require-dev": { + "phpunit/phpunit": "^6.5" + }, "scripts": { "test": [ "@phpunit" ], "phpunit": "php vendor/bin/phpunit" - } -} + } +} \ No newline at end of file