Skip to content

Commit

Permalink
Merge 97bdd41 into 39c68b4
Browse files Browse the repository at this point in the history
  • Loading branch information
heiglandreas committed May 4, 2016
2 parents 39c68b4 + 97bdd41 commit 1ee813f
Show file tree
Hide file tree
Showing 37 changed files with 233 additions and 69 deletions.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage_clover: clover.xml
json_path: coveralls-upload.json
src_dir: src
16 changes: 16 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->in('src')
->in('tests')
->notPath('TestAsset')
->notPath('_files')
->notPath('share')
->filter(function (SplFileInfo $file) {
if (strstr($file->getPath(), 'compatibility')) {
return false;
}
});
$config = Symfony\CS\Config\Config::create();
$config->level('psr2');
$config->finder($finder);
return $config;
81 changes: 68 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,79 @@
#
sudo: false
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- hhvm-nightly
- nightly

matrix:
fast_finish : true
allow_failures:
- php: 5.3
- php: 5.4
- php: hhvm-nightly
- php: nightly

include:
- php: 5.3
- php: 5.4
- php: 5.5
env:
- DEPS=lowest
- php: 5.5
env:
- DEPS=locked
- CHECK_CS=true
- php: 5.5
env:
- DEPS=latest
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=locked
- TEST_COVERAGE=true
- php: 5.6
env:
- DEPS=latest
- php: 7
env:
- DEPS=lowest
- php: 7
env:
- DEPS=locked
- php: 7
env:
- DEPS=latest
- php: hhvm
env:
- DEPS=lowest
- php: hhvm
env:
- DEPS=locked
- php: hhvm
env:
- DEPS=latest
- php: nightly
env:
- DEPS=lowest
- php: nightly
env:
- DEPS=locked
- php: nightly
env:
- DEPS=latest

before_install:
- travis_retry composer self-update
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi

install:
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require $COMPOSER_ARGS --dev satooshi/php-coveralls ; fi
- travis_retry composer install $COMPOSER_ARGS
- composer show --installed

script:
- composer update
- phpunit --coverage-text
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
- if [[ $CHECK_CS == 'true' ]]; then composer cs-check ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer upload-coverage ; fi
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009-2011 Andreas Heigl<andreas@heigl.org>
Copyright (c) 2009-2016 Andreas Heigl<andreas@heigl.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This package has the following requirements:
* Multibyte-Extension loaded
* Input has to be UTF8-encoded.

On loading the \Org\Heigl\Hyphenator\Hyphenator-class the internal encoding for
On loading the ````\Org\Heigl\Hyphenator\Hyphenator```-class the internal encoding for
the Multibyte-String-Extension will be set to UTF8.

# Installation:
Expand Down Expand Up @@ -51,7 +51,7 @@ Build-Status of the latest release can be found at http://travis-ci.org/#!/heigl

# Legal Stuff

Copyright (c) 2011-2013 Andreas Heigl<andreas@heigl.org>
Copyright (c) 2011-2016 Andreas Heigl<andreas@heigl.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
29 changes: 24 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "Org_Heigl/Hyphenator",
"name" : "Org_Heigl/Hyphenator",
"type" : "library",
"description" : "Word-Hyphenation for PHP",
"description" : "Word-Hyphenation for PHP based on the TeX-Hyphenation algorithm",
"keywords" : [ "hyphenation", "hyphenate"],
"homepage" : "http://github.com/heiglandreas/Org_Heigl_Hyphenator",
"license" : "MIT",
Expand All @@ -14,14 +14,33 @@
}
],
"require" : {
"php" : ">=5.3.0"
"php" : "^5.3||^7.0",
"ext-mbstring" : "*"
},
"require-dev" : {
"mockery/mockery" : "dev-master"
"mockery/mockery" : "^0.9",
"phpunit/phpunit": "^4.8||^5.3",
"fabpot/php-cs-fixer": "^1.7"
},
"autoload" : {
"psr-0" : {
"Org\\Heigl\\Hyphenator" : "src"
"Org\\Heigl\\Hyphenator\\" : "src"
}
},
"autoload-dev" : {
"psr-4" : {
"Org\\Heigl\\HyphenatorTest\\" : "tests"
}
},
"scripts": {
"check": [
"@cs-check",
"@test"
],
"upload-coverage": "coveralls -v",
"cs-check": "php-cs-fixer --version && php-cs-fixer fix -v --diff --dry-run",
"cs-fix": "php-cs-fixer fix -v",
"test": "phpunit",
"test-coverage": "phpunit --coverage-clover clover.xml"
}
}
19 changes: 3 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Org_Heigl_Hyphenator TestSuite">
<directory>tests/Org/</directory>
<directory>tests/</directory>
</testsuite>
</testsuites>
<groups>
Expand All @@ -19,21 +19,8 @@
</whitelist>
</filter>
<logging>
<!--
Adapt these paths to your special needs
-->
<log type="coverage-html" target="build/phpunit/coverage" charset="UTF-8"
<log type="coverage-html" target="build/phpunit/coverage" charset="UTF-8"
yui="true" highlight="false"
lowUpperBound="35" highLowerBound="70"/>
<!-- log type="coverage-xml" target="build/phpunit/coverage.xml"/>
<log type="graphviz" target="build/phpunit/logfile.dot"/>
<log type="json" target="build/phpunit/logfile.json"/>
<log type="metrics-xml" target="build/phpunit/metrics.xml"/>
<log type="plain" target="build/phpunit/logfile.txt"/>
<log type="pmd-xml" target="build/phpunit/pmd.xml" cpdMinLines="5" cpdMinMatches="70"/>
<log type="tap" target="build/phpunit/logfile.tap"/>
<log type="test-xml" target="build/phpunit/logfile.xml" logIncompleteSkipped="false"/>
<log type="testdox-html" target="build/phpunit/testdox.html"/>
<log type="testdox-text" target="build/phpunit/testdox.txt"/-->
</logging>
</logging>
</phpunit>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
115 changes: 115 additions & 0 deletions tests/Hyphenator/Filter/NonstandardFilterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php
/**
* Copyright (c) 2008-2011 Andreas Heigl<andreas@heigl.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @category Hyphenator
* @package Org\Heigl\Hyphenator
* @subpackage Filter
* @author Andreas Heigl <andreas@heigl.org>
* @copyright 2008-2011 Andreas Heigl<andreas@heigl.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT-License
* @version 2.0.1
* @since 02.12.2011
*/

namespace Org\Heigl\HyphenatorTest\Filter;

use \Org\Heigl\Hyphenator\Filter\NonStandardFilter;
use \Org\Heigl\Hyphenator\Options;
use \Org\Heigl\Hyphenator\Tokenizer as t;
use \Mockery as M;

/**
* This class tests the functionality of the class NonStandardFilter
*
* @category Hyphenator
* @package Org\Heigl\Hyphenator
* @subpackage Filter
* @author Andreas Heigl <andreas@heigl.org>
* @copyright 2008-2011 Andreas Heigl<andreas@heigl.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT-License
* @version 2.0.1
* @since 02.12.2011
*/
class NonStandardFilterTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider filterProvider
*/
public function testFilter($input, $pattern, $result)
{
$f = new NonStandardFilter();
$o = new Options();
$t = new t\WordToken($input);
$t->addPattern($pattern);
$r = new t\TokenRegistry();
$r->add($t);
$o->setHyphen('-');
$f->setOptions($o);
$this->assertSame($r, $f->run($r));
$this->assertEquals($result,$r->getTokenWithKey(0)->getHyphenatedContent());
}

public function filterProvider()
{
return array(
array('Donaudampfschifffahrt', array('auda' => '00100', 'pfsch'=>'001000', 'fff'=>'0010'), array ( 'Donau-dampfschifffahrt','Donaudampf-schifffahrt','Donaudampfschiff-fahrt')),
);
}

public function testFilterWithNonWordToken()
{
$tokenList = M::mock('\Org\Heigl\Hyphenator\Tokenizer\TokenRegistry');
$tokenList->shouldReceive('rewind')->once();
$tokenList->shouldReceive('valid')->twice()->andReturnValues(array(true, false));
$tokenList->shouldReceive('current')->once()->andReturn('foo');
$tokenList->shouldReceive('next')->once();
$tokenList->shouldReceive('key')->andReturn(0);

$filter = new NonStandardFilter();
$result = $filter->run($tokenList);

$this->assertSame($tokenList, $result);
}

public function testConcatenation()
{
$obj = new NonStandardFilter();

$token1 = M::mock('\Org\Heigl\Hyphenator\Tokenizer\Token');
$token1->shouldReceive('getFilteredContent')->once()->andReturn('a');

$token2 = M::mock('\Org\Heigl\Hyphenator\Tokenizer\Token');
$token2->shouldReceive('getFilteredContent')->once()->andReturn('b');

$tokenList = M::mock('\Org\Heigl\Hyphenator\Tokenizer\TokenRegistry');
$tokenList->shouldReceive('rewind')->once();
$tokenList->shouldReceive('valid')->times(3)->andReturnValues(array(true, true, false));
$tokenList->shouldReceive('current')->twice()->andReturnValues(array($token1, $token2));
$tokenList->shouldReceive('next')->twice();
$tokenList->shouldReceive('key')->andReturnValues(array(0, 1));

$method = \UnitTestHelper::getMethod($obj, '_concatenate');
$result = $method->invoke($obj, $tokenList);

$this->assertEquals('ab', $result);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function testHomeDirectory()
{
$this->assertAttributeEquals(null,'_defaultHomePath','\Org\Heigl\Hyphenator\Hyphenator');
$h = new h\Hyphenator();
$baseDirectory1 = dirname(dirname(dirname(__DIR__))) . '/src/Org/Heigl/Hyphenator/share';
$baseDirectory1 = dirname(__DIR__) . '/src/Org/Heigl/Hyphenator/share';
$this->assertEquals($baseDirectory1, \Org\Heigl\Hyphenator\Hyphenator::getDefaultHomePath());
$this->assertEquals($baseDirectory1, $h->getHomePath());
$baseDirectory2 = __DIR__ . '/share/tmp1';
Expand Down
31 changes: 0 additions & 31 deletions tests/phpunit.xml.dist

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 1ee813f

Please sign in to comment.