Skip to content

Commit 75c201f

Browse files
committed
init
0 parents  commit 75c201f

12 files changed

+344
-0
lines changed

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.gitattributes export-ignore
2+
.gitignore export-ignore
3+
.travis.yml export-ignore
4+
docs export-ignore
5+
tests export-ignore

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor
2+
composer.lock

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: php
2+
3+
php:
4+
- 5.3.3
5+
- 5.4
6+
7+
before_script:
8+
- composer install --no-interaction --quiet --dev
9+
10+
script: php tests/lint.php src/Kdyby/ tests/Kdyby/ && VERBOSE=true ./tests/run-tests.sh -s tests/

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Kdyby/Boilerplate [![Build Status](https://secure.travis-ci.org/Kdyby/Boilerplate.png?branch=master)](http://travis-ci.org/Kdyby/Boilerplate)
2+
===========================
3+
4+
5+
Requirements
6+
------------
7+
8+
Kdyby/Boilerplate requires PHP 5.3.2 or higher.
9+
10+
- [Nette Framework 2.0.x](https://github.com/nette/nette)
11+
12+
13+
Installation
14+
------------
15+
16+
The best way to install Kdyby/Boilerplate is using [Composer](http://getcomposer.org/):
17+
18+
```sh
19+
$ composer require kdyby/boilerplate:@dev
20+
```
21+
22+
23+
-----
24+
25+
Homepage [http://www.kdyby.org](http://www.kdyby.org) and repository [http://github.com/kdyby/boilerplate](http://github.com/kdyby/boilerplate).

composer.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name":"kdyby/boilerplate",
3+
"type":"library",
4+
"description":"Boilerplate for Kdyby components",
5+
"keywords":["nette", "kdyby"],
6+
"homepage":"http://kdyby.org",
7+
"license":["BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
8+
"authors":[
9+
{
10+
"name":"Filip Procházka",
11+
"homepage":"http://filip-prochazka.com"
12+
}
13+
],
14+
"support":{
15+
"email":"filip@prochazka.su",
16+
"issues":"https://github.com/kdyby/boilerplate/issues"
17+
},
18+
"require":{
19+
"nette/nette":"*"
20+
},
21+
"require-dev": {
22+
"nette/tester": "@dev"
23+
},
24+
"minimum-stability": "dev",
25+
"autoload":{
26+
"psr-0": {
27+
"Kdyby\\": "src/"
28+
}
29+
}
30+
}

license.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Licenses
2+
========
3+
4+
Good news! You may use Kdyby Framework under the terms of either
5+
the New BSD License or the GNU General Public License (GPL) version 2 or 3.
6+
7+
The BSD License is recommended for most projects. It is easy to understand and it
8+
places almost no restrictions on what you can do with the framework. If the GPL
9+
fits better to your project, you can use the framework under this license.
10+
11+
You don't have to notify anyone which license you are using. You can freely
12+
use Kdyby Framework in commercial projects as long as the copyright header
13+
remains intact.
14+
15+
16+
17+
New BSD License
18+
---------------
19+
20+
Copyright (c) 2008 Filip Procházka (http://filip-prochazka.com)
21+
All rights reserved.
22+
23+
Redistribution and use in source and binary forms, with or without modification,
24+
are permitted provided that the following conditions are met:
25+
26+
* Redistributions of source code must retain the above copyright notice,
27+
this list of conditions and the following disclaimer.
28+
29+
* Redistributions in binary form must reproduce the above copyright notice,
30+
this list of conditions and the following disclaimer in the documentation
31+
and/or other materials provided with the distribution.
32+
33+
* Neither the name of "Kdyby Framework" nor the names of its contributors
34+
may be used to endorse or promote products derived from this software
35+
without specific prior written permission.
36+
37+
This software is provided by the copyright holders and contributors "as is" and
38+
any express or implied warranties, including, but not limited to, the implied
39+
warranties of merchantability and fitness for a particular purpose are
40+
disclaimed. In no event shall the copyright owner or contributors be liable for
41+
any direct, indirect, incidental, special, exemplary, or consequential damages
42+
(including, but not limited to, procurement of substitute goods or services;
43+
loss of use, data, or profits; or business interruption) however caused and on
44+
any theory of liability, whether in contract, strict liability, or tort
45+
(including negligence or otherwise) arising in any way out of the use of this
46+
software, even if advised of the possibility of such damage.
47+
48+
49+
50+
GNU General Public License
51+
--------------------------
52+
53+
GPL licenses are very very long, so instead of including them here we offer
54+
you URLs with full text:
55+
56+
- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html)
57+
- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html)

tests/KdybyTests/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage.dat
2+
*.actual
3+
*.expected

tests/KdybyTests/bootstrap.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Kdyby (http://www.kdyby.org)
5+
*
6+
* Copyright (c) 2008 Filip Procházka (filip@prochazka.su)
7+
*
8+
* For the full copyright and license information, please view the file license.md that was distributed with this source code.
9+
*/
10+
11+
if (@!include __DIR__ . '/../../vendor/autoload.php') {
12+
echo 'Install Nette Tester using `composer update --dev`';
13+
exit(1);
14+
}
15+
16+
// configure environment
17+
Tester\Helpers::setup();
18+
class_alias('Tester\Assert', 'Assert');
19+
date_default_timezone_set('Europe/Prague');
20+
21+
// create temporary directory
22+
define('TEMP_DIR', __DIR__ . '/../tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid()));
23+
Tester\Helpers::purge(TEMP_DIR);
24+
25+
26+
$_SERVER = array_intersect_key($_SERVER, array_flip(array('PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS',
27+
'argc', 'argv')));
28+
$_SERVER['REQUEST_TIME'] = 1234567890;
29+
$_ENV = $_GET = $_POST = array();
30+
31+
32+
if (extension_loaded('xdebug')) {
33+
xdebug_disable();
34+
Tester\CodeCoverage\Collector::start(__DIR__ . '/coverage.dat');
35+
}
36+
37+
function id($val) {
38+
return $val;
39+
}
40+
41+
function run(Tester\TestCase $testCase) {
42+
$testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL);
43+
}

tests/conventions.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Test case file name
2+
===================
3+
4+
Nette\<class>.<method()>.<area>.<number>.phpt
5+
6+
Nette\Debug.phpt - tests for a class's basic behaviour
7+
Nette\Debug.fireLog().phpt - tests for a method's basic behaviour
8+
Nette\Debug.fireLog().inc - common code for more test cases
9+
Nette\Debug.fireLog().expect - expected raw output
10+
Nette\Debug.fireLog().area.phpt - tests for a specified area of class/method
11+
12+
- areas: basic, error, bug#123
13+
- numbers have three digits
14+
15+
16+
Test case phpDoc
17+
================
18+
19+
/**
20+
* Test: some test name
21+
*
22+
* @author John Doe
23+
* @phpVersion < 5.3 default operator is >=
24+
* @skip some reason why test is skipped
25+
* @phpIni short_open_tag=on
26+
*/

tests/lint.php

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/php
2+
<?php
3+
4+
/**
5+
* This file is part of the Kdyby (http://www.kdyby.org)
6+
*
7+
* Copyright (c) 2008 Filip Procházka (filip@prochazka.su)
8+
*
9+
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
10+
*/
11+
12+
$parseOptions = function () use ($_SERVER) {
13+
$options = array('quiet' => false, 'files' => array());
14+
foreach (array_keys(getopt('qh', array('quiet', 'help'))) as $arg) {
15+
switch ($arg) {
16+
case 'q':
17+
case 'quiet':
18+
$options['quiet'] = true;
19+
break;
20+
21+
case 'h':
22+
case 'help':
23+
default:
24+
echo <<<HELP
25+
usage: lint [-q] [path]
26+
27+
options:
28+
-q, --quiet: disable verbose output
29+
-h, --help: display this help screen
30+
31+
HELP;
32+
exit(0);
33+
}
34+
}
35+
36+
stream_set_blocking(STDIN, FALSE);
37+
while ($line = trim(fgets(STDIN))) {
38+
$options['files'][] = $_SERVER['PWD'] . '/' . $line;
39+
}
40+
41+
if (empty($options['files']) && $_SERVER['argc'] > 1) {
42+
foreach ($_SERVER['argv'] as $i => $arg) {
43+
if (substr($arg, 0, 1) === '-' || $i === 0) continue;
44+
$options['files'][] = $arg;
45+
}
46+
}
47+
48+
if (empty($options['files'])) $options['files'][] = $_SERVER['PWD'];
49+
50+
foreach ($options['files'] as $i => $file) {
51+
if (($options['files'][$i] = realpath($file)) !== false) continue;
52+
echo "$file is not a file or directory.\n";
53+
exit(1);
54+
}
55+
56+
return $options;
57+
};
58+
59+
$echo = function () use (&$context) {
60+
if ($context['quiet']) return;
61+
foreach (func_get_args() as $arg) echo $arg;
62+
};
63+
64+
$lintFile = function ($path) use (&$echo, &$context) {
65+
if (substr($path, -4) != '.php') return;
66+
67+
if ($context['filesCount'] % 63 == 0) {
68+
$echo("\n");
69+
}
70+
71+
exec("php -l " . escapeshellarg($path) . " 2>&1 1> /dev/null", $output, $code);
72+
if ($code) {
73+
$context['errors'][] = implode($output);
74+
$echo('E');
75+
} else {
76+
$echo('.');
77+
}
78+
79+
$context['filesCount']++;
80+
};
81+
82+
$check = function ($path) use (&$check, &$lintFile, &$context) {
83+
if (!is_dir($path)) return $lintFile($path);
84+
foreach (scandir($path) as $item) {
85+
if ($item == '.' || $item == '..') continue;
86+
$check(rtrim($path, '/') . '/' . $item);
87+
}
88+
};
89+
90+
91+
$context = $parseOptions();
92+
$context['filesCount'] = 0;
93+
$context['errors'] = array();
94+
foreach ($context['files'] as $file) $check($file);
95+
if ($context['errors']) {
96+
$echo("\n\n", implode($context['errors']));
97+
}
98+
99+
$echo(
100+
"\n\n", ($context['errors'] ? 'FAILED' : 'OK'),
101+
' (', $context['filesCount'], " files checked, ", count($context['errors']), " errors)\n"
102+
);
103+
exit($context['errors'] ? 1 : 0);

tests/php.ini-unix

Whitespace-only changes.

tests/run-tests.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
3+
# Path to this script's directory
4+
dir=$(cd `dirname $0` && pwd)
5+
6+
# Path to test runner script
7+
runnerScript="$dir/../vendor/nette/tester/Tester/tester.php"
8+
if [ ! -f "$runnerScript" ]; then
9+
echo "Nette Tester is missing. You can install it using Composer:" >&2
10+
echo "php composer.phar update --dev." >&2
11+
exit 2
12+
fi
13+
14+
# Path to php.ini if passed as argument option
15+
phpIni=
16+
while getopts ":c:" opt; do
17+
case $opt in
18+
c) phpIni="$OPTARG"
19+
;;
20+
21+
:) echo "Missing argument for -$OPTARG option" >&2
22+
exit 2
23+
;;
24+
esac
25+
done
26+
27+
# Runs tests with script's arguments, add default php.ini if not specified
28+
# Doubled -c option intentionally
29+
if [ -n "$phpIni" ]; then
30+
php -c "$phpIni" "$runnerScript" -j 20 "$@"
31+
else
32+
php -c "$dir/php.ini-unix" "$runnerScript" -j 20 -c "$dir/php.ini-unix" "$@"
33+
fi
34+
error=$?
35+
36+
# Print *.actual content if tests failed
37+
if [ "${VERBOSE-false}" != "false" -a $error -ne 0 ]; then
38+
for i in $(find . -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
39+
exit $error
40+
fi

0 commit comments

Comments
 (0)