Skip to content

Commit

Permalink
Update beta-modular
Browse files Browse the repository at this point in the history
  • Loading branch information
dusta committed Jun 30, 2018
1 parent 864fa45 commit 1530c85
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 36 deletions.
35 changes: 14 additions & 21 deletions app/Bootstrap.php
Expand Up @@ -10,7 +10,7 @@
use Dframe\Session;
use Dframe\Messages;
use Dframe\Token;
use Dframe\Database\Database;


require_once dirname(__DIR__) . '/web/config.php';

Expand All @@ -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;
}
Expand Down
20 changes: 20 additions & 0 deletions app/Model/Model.php
Expand Up @@ -9,6 +9,7 @@

namespace Model;

use Dframe\Database\Database;
/**
* This class includes methods for models.
*
Expand All @@ -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();
}
}

}
11 changes: 4 additions & 7 deletions app/Tests/RunTest.php
Expand Up @@ -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';
Expand All @@ -28,7 +25,7 @@ class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
* @author Sławek Kaleta <slaszka@gmail.com>
*/

class RunTest extends \PHPUnit\Framework\TestCase
class RunTest extends TestCase
{


Expand All @@ -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());

Expand Down
6 changes: 3 additions & 3 deletions app/View/View.php
@@ -1,4 +1,5 @@
<?php

/**
* Project Name
* Copyright (c) Firstname Lastname
Expand All @@ -17,10 +18,9 @@
abstract class View extends \Dframe\View
{

public function __construct($baseClass)
public function start()
{
$this->setView(new \Dframe\View\SmartyView());
parent::__construct($baseClass);
$this->view = new \Dframe\View\SmartyView();
}

}
27 changes: 22 additions & 5 deletions composer.json
Expand Up @@ -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"
}
}
}
}

0 comments on commit 1530c85

Please sign in to comment.