Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Commit

Permalink
#328 nicer path for regexes.php
Browse files Browse the repository at this point in the history
  • Loading branch information
lstrojny committed Jan 19, 2014
1 parent fec0947 commit 4784230
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion php/src/UAParser/AbstractParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ protected function replaceString($regex, $key, $string)
*/
protected static function getDefaultFile()
{
return static::$defaultFile ? static::$defaultFile : __DIR__ . '/../../resources/regexes.php';
return static::$defaultFile
? static::$defaultFile
: realpath(__DIR__ . '/../../resources') . DIRECTORY_SEPARATOR . 'regexes.php';
}
}
13 changes: 9 additions & 4 deletions php/tests/UAParser/Tests/AbstractParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
namespace UAParser\Tests;

use PHPUnit_Framework_TestCase as AbstractTestCase;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Yaml\Yaml;
use UAParser\AbstractParser;
use UAParser\Parser;

abstract class AbstractParserTest extends AbstractTestCase
{
Expand Down Expand Up @@ -58,6 +54,15 @@ public function testExceptionOnFileNotFoundInvalidDefault()
$parserClassName::create();
}

public function testDefaultFileIsAbsolute()
{
$class = new \ReflectionClass('UAParser\AbstractParser');
$method = $class->getMethod('getDefaultFile');
$method->setAccessible(true);

$this->assertNotContains('..', $method->invoke(null));
}

public function tearDown()
{
AbstractParser::$defaultFile = null;
Expand Down

0 comments on commit 4784230

Please sign in to comment.