Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
fprochazka committed Mar 9, 2013
0 parents commit 021b95a
Show file tree
Hide file tree
Showing 12 changed files with 345 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
docs export-ignore
tests export-ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: php

php:
- 5.3.3
- 5.4

before_script:
- composer self-update
- composer install --no-interaction --quiet --dev

script: php tests/lint.php src/Kdyby/ tests/KdybyTests/ && VERBOSE=true ./tests/run-tests.sh -s tests/KdybyTests/
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Kdyby/Translation [![Build Status](https://secure.travis-ci.org/Kdyby/Translation.png?branch=master)](http://travis-ci.org/Kdyby/Translation)
===========================


Requirements
------------

Kdyby/Translation requires PHP 5.3.2 or higher.

- [Nette Framework 2.0.x](https://github.com/nette/nette)


Installation
------------

The best way to install Kdyby/Translation is using [Composer](http://getcomposer.org/):

```sh
$ composer require kdyby/translation:@dev
```


-----

Homepage [http://www.kdyby.org](http://www.kdyby.org) and repository [http://github.com/kdyby/Translation](http://github.com/kdyby/Translation).
30 changes: 30 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "kdyby/translation",
"type": "library",
"description": "Integration of Symfony/Translation into Nette Framework",
"keywords": ["nette", "kdyby", "translation"],
"homepage": "http://kdyby.org",
"license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
"authors": [
{
"name": "Filip Procházka",
"homepage": "http://filip-prochazka.com"
}
],
"support": {
"email": "[email protected]",
"issues": "https://github.com/kdyby/translation/issues"
},
"require": {
"nette/nette": "@dev",
"symfony/translation": "2.2.*"
},
"require-dev": {
"nette/tester": "@dev"
},
"autoload": {
"psr-0": {
"Kdyby\\Translation": "src/Translation/"
}
}
}
57 changes: 57 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Licenses
========

Good news! You may use Kdyby Framework under the terms of either
the New BSD License or the GNU General Public License (GPL) version 2 or 3.

The BSD License is recommended for most projects. It is easy to understand and it
places almost no restrictions on what you can do with the framework. If the GPL
fits better to your project, you can use the framework under this license.

You don't have to notify anyone which license you are using. You can freely
use Kdyby Framework in commercial projects as long as the copyright header
remains intact.



New BSD License
---------------

Copyright (c) 2008 Filip Procházka (http://filip-prochazka.com)
All rights reserved.

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.

* Neither the name of "Kdyby Framework" nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

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.



GNU General Public License
--------------------------

GPL licenses are very very long, so instead of including them here we offer
you URLs with full text:

- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html)
- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html)
3 changes: 3 additions & 0 deletions tests/KdybyTests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage.dat
*.actual
*.expected
43 changes: 43 additions & 0 deletions tests/KdybyTests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.md that was distributed with this source code.
*/

if (@!include __DIR__ . '/../../vendor/autoload.php') {
echo 'Install Nette Tester using `composer update --dev`';
exit(1);
}

// configure environment
Tester\Helpers::setup();
class_alias('Tester\Assert', 'Assert');
date_default_timezone_set('Europe/Prague');

// create temporary directory
define('TEMP_DIR', __DIR__ . '/../tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid()));
Tester\Helpers::purge(TEMP_DIR);


$_SERVER = array_intersect_key($_SERVER, array_flip(array('PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS',
'argc', 'argv')));
$_SERVER['REQUEST_TIME'] = 1234567890;
$_ENV = $_GET = $_POST = array();


if (extension_loaded('xdebug')) {
xdebug_disable();
Tester\CodeCoverage\Collector::start(__DIR__ . '/coverage.dat');
}

function id($val) {
return $val;
}

function run(Tester\TestCase $testCase) {
$testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL);
}
26 changes: 26 additions & 0 deletions tests/conventions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Test case file name
===================

Nette\<class>.<method()>.<area>.<number>.phpt

Nette\Debug.phpt - tests for a class's basic behaviour
Nette\Debug.fireLog().phpt - tests for a method's basic behaviour
Nette\Debug.fireLog().inc - common code for more test cases
Nette\Debug.fireLog().expect - expected raw output
Nette\Debug.fireLog().area.phpt - tests for a specified area of class/method

- areas: basic, error, bug#123
- numbers have three digits


Test case phpDoc
================

/**
* Test: some test name
*
* @author John Doe
* @phpVersion < 5.3 default operator is >=
* @skip some reason why test is skipped
* @phpIni short_open_tag=on
*/
103 changes: 103 additions & 0 deletions tests/lint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/php
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

$parseOptions = function () use ($_SERVER) {
$options = array('quiet' => false, 'files' => array());
foreach (array_keys(getopt('qh', array('quiet', 'help'))) as $arg) {
switch ($arg) {
case 'q':
case 'quiet':
$options['quiet'] = true;
break;

case 'h':
case 'help':
default:
echo <<<HELP
usage: lint [-q] [path]
options:
-q, --quiet: disable verbose output
-h, --help: display this help screen
HELP;
exit(0);
}
}

stream_set_blocking(STDIN, FALSE);
while ($line = trim(fgets(STDIN))) {
$options['files'][] = $_SERVER['PWD'] . '/' . $line;
}

if (empty($options['files']) && $_SERVER['argc'] > 1) {
foreach ($_SERVER['argv'] as $i => $arg) {
if (substr($arg, 0, 1) === '-' || $i === 0) continue;
$options['files'][] = $arg;
}
}

if (empty($options['files'])) $options['files'][] = $_SERVER['PWD'];

foreach ($options['files'] as $i => $file) {
if (($options['files'][$i] = realpath($file)) !== false) continue;
echo "$file is not a file or directory.\n";
exit(1);
}

return $options;
};

$echo = function () use (&$context) {
if ($context['quiet']) return;
foreach (func_get_args() as $arg) echo $arg;
};

$lintFile = function ($path) use (&$echo, &$context) {
if (substr($path, -4) != '.php') return;

if ($context['filesCount'] % 63 == 0) {
$echo("\n");
}

exec("php -l " . escapeshellarg($path) . " 2>&1 1> /dev/null", $output, $code);
if ($code) {
$context['errors'][] = implode($output);
$echo('E');
} else {
$echo('.');
}

$context['filesCount']++;
};

$check = function ($path) use (&$check, &$lintFile, &$context) {
if (!is_dir($path)) return $lintFile($path);
foreach (scandir($path) as $item) {
if ($item == '.' || $item == '..') continue;
$check(rtrim($path, '/') . '/' . $item);
}
};


$context = $parseOptions();
$context['filesCount'] = 0;
$context['errors'] = array();
foreach ($context['files'] as $file) $check($file);
if ($context['errors']) {
$echo("\n\n", implode($context['errors']));
}

$echo(
"\n\n", ($context['errors'] ? 'FAILED' : 'OK'),
' (', $context['filesCount'], " files checked, ", count($context['errors']), " errors)\n"
);
exit($context['errors'] ? 1 : 0);
Empty file added tests/php.ini-unix
Empty file.
40 changes: 40 additions & 0 deletions tests/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

# Path to this script's directory
dir=$(cd `dirname $0` && pwd)

# Path to test runner script
runnerScript="$dir/../vendor/nette/tester/Tester/tester.php"
if [ ! -f "$runnerScript" ]; then
echo "Nette Tester is missing. You can install it using Composer:" >&2
echo "php composer.phar update --dev." >&2
exit 2
fi

# Path to php.ini if passed as argument option
phpIni=
while getopts ":c:" opt; do
case $opt in
c) phpIni="$OPTARG"
;;

:) echo "Missing argument for -$OPTARG option" >&2
exit 2
;;
esac
done

# Runs tests with script's arguments, add default php.ini if not specified
# Doubled -c option intentionally
if [ -n "$phpIni" ]; then
php -c "$phpIni" "$runnerScript" -j 20 "$@"
else
php -c "$dir/php.ini-unix" "$runnerScript" -j 20 -c "$dir/php.ini-unix" "$@"
fi
error=$?

# Print *.actual content if tests failed
if [ "${VERBOSE-false}" != "false" -a $error -ne 0 ]; then
for i in $(find . -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
exit $error
fi

0 comments on commit 021b95a

Please sign in to comment.