Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webbasics
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
webbasics
Commits
dddd5f09
Commit
dddd5f09
authored
Jul 15, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed project name to 'WebBasics'.
parent
5c420197
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
40 additions
and
40 deletions
+40
-40
README.txt
README.txt
+1
-1
autoloader.php
autoloader.php
+2
-2
base.php
base.php
+6
-6
logger.php
logger.php
+2
-2
node.php
node.php
+2
-2
phpdoc.dist.xml
phpdoc.dist.xml
+2
-2
phpunit.xml
phpunit.xml
+1
-1
router.php
router.php
+2
-2
template.php
template.php
+3
-3
tests/test_autoloader.php
tests/test_autoloader.php
+4
-4
tests/test_base.php
tests/test_base.php
+4
-4
tests/test_logger.php
tests/test_logger.php
+1
-1
tests/test_node.php
tests/test_node.php
+1
-1
tests/test_router.php
tests/test_router.php
+1
-1
tests/test_template.php
tests/test_template.php
+8
-8
No files found.
README.txt
View file @
dddd5f09
-------
-------
Summary
Summary
-------
-------
BasicWeb
is a set of classes that provides the minimal functionalities of a
WebBasics
is a set of classes that provides the minimal functionalities of a
website. The core exists of a class autoloader, a template parser, a logger
website. The core exists of a class autoloader, a template parser, a logger
and some array manipulation functions. No MVC 'model' implementation is
and some array manipulation functions. No MVC 'model' implementation is
included, there are already many of these out there (PHPActiveRecord is
included, there are already many of these out there (PHPActiveRecord is
...
...
autoloader.php
View file @
dddd5f09
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* @date 13-07-2012
* @date 13-07-2012
*/
*/
namespace
BasicWeb
;
namespace
WebBasics
;
require_once
'base.php'
;
require_once
'base.php'
;
...
@@ -51,7 +51,7 @@ require_once 'base.php';
...
@@ -51,7 +51,7 @@ require_once 'base.php';
* $baz = new Baz(); // Throws a FileNotFoundError, since 'other_classes/baz.php' does not exist
* $baz = new Baz(); // Throws a FileNotFoundError, since 'other_classes/baz.php' does not exist
* </code>
* </code>
*
*
* @package
BasicWeb
* @package
WebBasics
*/
*/
class
Autoloader
extends
Base
{
class
Autoloader
extends
Base
{
/**
/**
...
...
base.php
View file @
dddd5f09
<?php
<?php
/**
/**
* Commonly used classes used in the
BasicWeb
package.
* Commonly used classes used in the
WebBasics
package.
*
*
* @author Taddeus Kroes
* @author Taddeus Kroes
* @version 1.0
* @version 1.0
* @date 13-07-2012
* @date 13-07-2012
*/
*/
namespace
BasicWeb
;
namespace
WebBasics
;
require_once
'logger.php'
;
require_once
'logger.php'
;
/**
/**
* Base class for instantiable classes in the
BasicWeb
package.
* Base class for instantiable classes in the
WebBasics
package.
*
*
* The base class defines a static 'create' method that acts as a chainable
* The base class defines a static 'create' method that acts as a chainable
* shortcut for the class constructor:
* shortcut for the class constructor:
...
@@ -37,7 +37,7 @@ require_once 'logger.php';
...
@@ -37,7 +37,7 @@ require_once 'logger.php';
* $foo->method();
* $foo->method();
* </code>
* </code>
*
*
* @package
BasicWeb
* @package
WebBasics
*/
*/
abstract
class
Base
{
abstract
class
Base
{
/**
/**
...
@@ -60,7 +60,7 @@ abstract class Base {
...
@@ -60,7 +60,7 @@ abstract class Base {
/**
/**
* Exception, thrown when a required file does not exist.
* Exception, thrown when a required file does not exist.
*
*
* @package
BasicWeb
* @package
WebBasics
*/
*/
class
FileNotFoundError
extends
\RuntimeException
{
class
FileNotFoundError
extends
\RuntimeException
{
/**
/**
...
@@ -85,7 +85,7 @@ class FileNotFoundError extends \RuntimeException {
...
@@ -85,7 +85,7 @@ class FileNotFoundError extends \RuntimeException {
*
*
* @param string $format The string to format.
* @param string $format The string to format.
* @param array $params An associative array with parameters that are used in $format.
* @param array $params An associative array with parameters that are used in $format.
* @package
BasicWeb
* @package
WebBasics
*/
*/
function
asprintf
(
$format
,
array
$params
)
{
function
asprintf
(
$format
,
array
$params
)
{
return
preg_replace_callback
(
return
preg_replace_callback
(
...
...
logger.php
View file @
dddd5f09
...
@@ -7,14 +7,14 @@
...
@@ -7,14 +7,14 @@
* @date 13-07-2012
* @date 13-07-2012
*/
*/
namespace
BasicWeb
;
namespace
WebBasics
;
/**
/**
* Logger class.
* Logger class.
*
*
* A Logger object provides five functions to process log messages.
* A Logger object provides five functions to process log messages.
*
*
* @package
BasicWeb
* @package
WebBasics
*/
*/
class
Logger
{
class
Logger
{
const
CRITICAL
=
0
;
const
CRITICAL
=
0
;
...
...
node.php
View file @
dddd5f09
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* @date 13-07-2012
* @date 13-07-2012
*/
*/
namespace
BasicWeb
;
namespace
WebBasics
;
require_once
'base.php'
;
require_once
'base.php'
;
...
@@ -17,7 +17,7 @@ require_once 'base.php';
...
@@ -17,7 +17,7 @@ require_once 'base.php';
* Each tree node has a (non-unique) name, a list of variables, and zero or
* Each tree node has a (non-unique) name, a list of variables, and zero or
* more children.
* more children.
*
*
* @package
BasicWeb
* @package
WebBasics
*/
*/
class
Node
extends
Base
{
class
Node
extends
Base
{
/**
/**
...
...
phpdoc.dist.xml
View file @
dddd5f09
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<phpdoc>
<phpdoc>
<title>
BasicWeb
documentation
</title>
<title>
WebBasics
documentation
</title>
<parser>
<parser>
<default-package-name>
BasicWeb
</default-package-name>
<default-package-name>
WebBasics
</default-package-name>
<target>
build/docs
</target>
<target>
build/docs
</target>
</parser>
</parser>
<transformer>
<transformer>
...
...
phpunit.xml
View file @
dddd5f09
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
convertWarningsToExceptions=
"true"
convertWarningsToExceptions=
"true"
stopOnError=
"true"
>
stopOnError=
"true"
>
<testsuites>
<testsuites>
<testsuite
name=
"
BasicWeb
test suite"
>
<testsuite
name=
"
WebBasics
test suite"
>
<directory
prefix=
"test_"
suffix=
".php"
>
tests
</directory>
<directory
prefix=
"test_"
suffix=
".php"
>
tests
</directory>
</testsuite>
</testsuite>
</testsuites>
</testsuites>
...
...
router.php
View file @
dddd5f09
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* @date 14-07-2012
* @date 14-07-2012
*/
*/
namespace
BasicWeb
;
namespace
WebBasics
;
require_once
'base.php'
;
require_once
'base.php'
;
...
@@ -47,7 +47,7 @@ require_once 'base.php';
...
@@ -47,7 +47,7 @@ require_once 'base.php';
* $response = $router->call_handler('/contact'); // 'This is the contact page.'
* $response = $router->call_handler('/contact'); // 'This is the contact page.'
* </code>
* </code>
*
*
* @package
BasicWeb
* @package
WebBasics
*/
*/
class
Router
extends
Base
{
class
Router
extends
Base
{
/**
/**
...
...
template.php
View file @
dddd5f09
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* @date 14-07-2012
* @date 14-07-2012
*/
*/
namespace
BasicWeb
;
namespace
WebBasics
;
require_once
'node.php'
;
require_once
'node.php'
;
...
@@ -67,7 +67,7 @@ require_once 'node.php';
...
@@ -67,7 +67,7 @@ require_once 'node.php';
* </html>
* </html>
* </code>
* </code>
*
*
* @package
BasicWeb
* @package
WebBasics
*/
*/
class
Template
extends
Node
{
class
Template
extends
Node
{
/**
/**
...
@@ -359,7 +359,7 @@ class Template extends Node {
...
@@ -359,7 +359,7 @@ class Template extends Node {
/**
/**
* Error, thrown when an error occurs during the parsing of a template file.
* Error, thrown when an error occurs during the parsing of a template file.
*
*
* @package
BasicWeb
* @package
WebBasics
*/
*/
class
ParseError
extends
\RuntimeException
{
class
ParseError
extends
\RuntimeException
{
/**
/**
...
...
tests/test_autoloader.php
View file @
dddd5f09
<?php
<?php
require_once
'autoloader.php'
;
require_once
'autoloader.php'
;
use
BasicWeb
\Autoloader
;
use
WebBasics
\Autoloader
;
define
(
'PATH'
,
'tests/_files/'
);
define
(
'PATH'
,
'tests/_files/'
);
...
@@ -31,7 +31,7 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
...
@@ -31,7 +31,7 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
* @depends test_set_root_namespace
* @depends test_set_root_namespace
*/
*/
function
test_strip_root_namespace
()
{
function
test_strip_root_namespace
()
{
$strip
=
new
ReflectionMethod
(
'
BasicWeb
\Autoloader'
,
'strip_root_namespace'
);
$strip
=
new
ReflectionMethod
(
'
WebBasics
\Autoloader'
,
'strip_root_namespace'
);
$strip
->
setAccessible
(
true
);
$strip
->
setAccessible
(
true
);
$this
->
autoloader
->
set_root_namespace
(
'Foo'
);
$this
->
autoloader
->
set_root_namespace
(
'Foo'
);
...
@@ -85,7 +85,7 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
...
@@ -85,7 +85,7 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
/**
/**
* @depends test_load_class_not_found
* @depends test_load_class_not_found
* @expectedException
BasicWeb
\FileNotFoundError
* @expectedException
WebBasics
\FileNotFoundError
* @expectedExceptionMessage File "tests/_files/foobar.php" does not exist.
* @expectedExceptionMessage File "tests/_files/foobar.php" does not exist.
*/
*/
function
test_load_class_not_found_error
()
{
function
test_load_class_not_found_error
()
{
...
@@ -95,7 +95,7 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
...
@@ -95,7 +95,7 @@ class AutoloaderTest extends PHPUnit_Framework_TestCase {
/**
/**
* @depends test_load_class_not_found
* @depends test_load_class_not_found
* @expectedException
BasicWeb
\FileNotFoundError
* @expectedException
WebBasics
\FileNotFoundError
* @expectedExceptionMessage File "tests/_files/foobar.php" does not exist.
* @expectedExceptionMessage File "tests/_files/foobar.php" does not exist.
*/
*/
function
test_load_class_not_found_noerror_overwrite
()
{
function
test_load_class_not_found_noerror_overwrite
()
{
...
...
tests/test_base.php
View file @
dddd5f09
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require_once
'base.php'
;
require_once
'base.php'
;
class
BaseExtension
extends
BasicWeb
\Base
{
class
BaseExtension
extends
WebBasics
\Base
{
function
__construct
(
$foo
,
$bar
)
{
function
__construct
(
$foo
,
$bar
)
{
$this
->
foo
=
$foo
;
$this
->
foo
=
$foo
;
$this
->
bar
=
$bar
;
$this
->
bar
=
$bar
;
...
@@ -15,10 +15,10 @@ class BaseTest extends PHPUnit_Framework_TestCase {
...
@@ -15,10 +15,10 @@ class BaseTest extends PHPUnit_Framework_TestCase {
}
}
function
test_asprintf
()
{
function
test_asprintf
()
{
$this
->
assertEquals
(
BasicWeb
\asprintf
(
'%(foo) baz'
,
array
(
'foo'
=>
'bar'
)),
'bar baz'
);
$this
->
assertEquals
(
WebBasics
\asprintf
(
'%(foo) baz'
,
array
(
'foo'
=>
'bar'
)),
'bar baz'
);
$this
->
assertEquals
(
BasicWeb
\asprintf
(
'%(foo) baz %(foo)'
,
$this
->
assertEquals
(
WebBasics
\asprintf
(
'%(foo) baz %(foo)'
,
array
(
'foo'
=>
'bar'
)),
'bar baz bar'
);
array
(
'foo'
=>
'bar'
)),
'bar baz bar'
);
$this
->
assertEquals
(
BasicWeb
\asprintf
(
'%(bar) baz %(foo)'
,
$this
->
assertEquals
(
WebBasics
\asprintf
(
'%(bar) baz %(foo)'
,
array
(
'foo'
=>
'bar'
,
'bar'
=>
'foobar'
)),
'foobar baz bar'
);
array
(
'foo'
=>
'bar'
,
'bar'
=>
'foobar'
)),
'foobar baz bar'
);
}
}
}
}
...
...
tests/test_logger.php
View file @
dddd5f09
<?php
<?php
require_once
'logger.php'
;
require_once
'logger.php'
;
use
BasicWeb
\Logger
;
use
WebBasics
\Logger
;
define
(
'NAME'
,
'Testlogger'
);
define
(
'NAME'
,
'Testlogger'
);
define
(
'FORMAT'
,
'%(level): %(message)'
);
define
(
'FORMAT'
,
'%(level): %(message)'
);
...
...
tests/test_node.php
View file @
dddd5f09
<?php
<?php
require_once
'node.php'
;
require_once
'node.php'
;
use
\
BasicWeb
\Node
;
use
\
WebBasics
\Node
;
class
NodeTest
extends
PHPUnit_Framework_TestCase
{
class
NodeTest
extends
PHPUnit_Framework_TestCase
{
var
$autoloader
;
var
$autoloader
;
...
...
tests/test_router.php
View file @
dddd5f09
<?php
<?php
require_once
'router.php'
;
require_once
'router.php'
;
use
BasicWeb
\Router
;
use
WebBasics
\Router
;
function
test_handler_no_args
()
{
function
test_handler_no_args
()
{
return
true
;
return
true
;
...
...
tests/test_template.php
View file @
dddd5f09
<?php
<?php
require_once
'template.php'
;
require_once
'template.php'
;
use
BasicWeb
\Template
;
use
WebBasics
\Template
;
use
BasicWeb
\Node
;
use
WebBasics
\Node
;
define
(
'TEMPLATES_DIR'
,
'tests/_files/templates/'
);
define
(
'TEMPLATES_DIR'
,
'tests/_files/templates/'
);
...
@@ -33,7 +33,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
...
@@ -33,7 +33,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
}
}
/**
/**
* @expectedException
BasicWeb
\FileNotFoundError
* @expectedException
WebBasics
\FileNotFoundError
* @expectedExceptionMessage Directory "non_existing_folder/" does not exist.
* @expectedExceptionMessage Directory "non_existing_folder/" does not exist.
*/
*/
function
test_add_root_failure
()
{
function
test_add_root_failure
()
{
...
@@ -41,7 +41,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
...
@@ -41,7 +41,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
}
}
function
assert_include_path_equals
(
$expected
)
{
function
assert_include_path_equals
(
$expected
)
{
$include_path
=
new
ReflectionProperty
(
'
BasicWeb
\Template'
,
'include_path'
);
$include_path
=
new
ReflectionProperty
(
'
WebBasics
\Template'
,
'include_path'
);
$include_path
->
setAccessible
(
true
);
$include_path
->
setAccessible
(
true
);
$this
->
assertEquals
(
$expected
,
$include_path
->
getValue
());
$this
->
assertEquals
(
$expected
,
$include_path
->
getValue
());
}
}
...
@@ -146,7 +146,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
...
@@ -146,7 +146,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
/**
/**
* @depends test_parse_blocks_blocks
* @depends test_parse_blocks_blocks
* @expectedException
BasicWeb
\ParseError
* @expectedException
WebBasics
\ParseError
* @expectedExceptionMessage Parse error in file tests/_files/templates/unexpected_end.tpl, line 5: unexpected {end}
* @expectedExceptionMessage Parse error in file tests/_files/templates/unexpected_end.tpl, line 5: unexpected {end}
*/
*/
function
test_parse_blocks_unexpected_end
()
{
function
test_parse_blocks_unexpected_end
()
{
...
@@ -155,7 +155,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
...
@@ -155,7 +155,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
/**
/**
* @depends test_parse_blocks_blocks
* @depends test_parse_blocks_blocks
* @expectedException
BasicWeb
\ParseError
* @expectedException
WebBasics
\ParseError
* @expectedExceptionMessage Parse error in file tests/_files/templates/missing_end.tpl, line 6: missing {end}
* @expectedExceptionMessage Parse error in file tests/_files/templates/missing_end.tpl, line 6: missing {end}
*/
*/
function
test_parse_blocks_missing_end
()
{
function
test_parse_blocks_missing_end
()
{
...
@@ -206,7 +206,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
...
@@ -206,7 +206,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
}
}
function
assert_replaces
(
$expected
,
$variable
)
{
function
assert_replaces
(
$expected
,
$variable
)
{
$rm
=
new
ReflectionMethod
(
'
BasicWeb
\Template'
,
'replace_variable'
);
$rm
=
new
ReflectionMethod
(
'
WebBasics
\Template'
,
'replace_variable'
);
$rm
->
setAccessible
(
true
);
$rm
->
setAccessible
(
true
);
$this
->
assertEquals
(
$expected
,
$rm
->
invoke
(
null
,
$variable
,
$this
->
data
));
$this
->
assertEquals
(
$expected
,
$rm
->
invoke
(
null
,
$variable
,
$this
->
data
));
}
}
...
@@ -255,7 +255,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
...
@@ -255,7 +255,7 @@ class TemplateTest extends PHPUnit_Framework_TestCase {
}
}
/*function assert_block_renders($expected_file, $block, $data) {
/*function assert_block_renders($expected_file, $block, $data) {
$rm = new ReflectionMethod('
BasicWeb
\Template', 'render_block');
$rm = new ReflectionMethod('
WebBasics
\Template', 'render_block');
$rm->setAccessible(true);
$rm->setAccessible(true);
$expected_file = "tests/_files/rendered/$expected_file.html";
$expected_file = "tests/_files/rendered/$expected_file.html";
$this->assertStringEqualsFile($expected_file, $rm->invoke(null, $block, $data));
$this->assertStringEqualsFile($expected_file, $rm->invoke(null, $block, $data));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment