Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 0 additions & 54 deletions .circleci/config.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PHPUnit

on:
push:
branches: [ master, '2.0' ]
pull_request:
branches: [ master, '2.0' ]

jobs:
test:
runs-on: ubuntu-latest

name: PHP 7.4

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: bcmath
coverage: xdebug

- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress

- name: Run PHPUnit
run: vendor/bin/phpunit --coverage-text=coverage.txt

- name: Check coverage
run: |
cat coverage.txt
COVERAGE=$(grep -A3 'Summary:' coverage.txt | grep 'Lines:' | grep -oP '\d+\.\d+(?=%)')
THRESHOLD=98
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
echo "Coverage is $COVERAGE%, below ${THRESHOLD}% threshold"
exit 1
fi
echo "Coverage is $COVERAGE% (threshold: ${THRESHOLD}%)"
14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
}
],
"config": {
"allow-plugins": false
"allow-plugins": false,
"audit": {
"block-insecure": false
}
},
"require": {
"php": ">=7.0",
"php": "~7.4",
"psr/log": "~1.0",
"illuminate/container": "~5.4",
"illuminate/support": "~5.4",
Expand All @@ -27,7 +30,7 @@
"monolog/monolog": "~1.10",
"packaged/figlet": "~0",
"packaged/config": "~1.0",
"packaged/helpers": "~1.0",
"packaged/helpers": "~1.0|~2.0",
"packaged/api": "~1.0",
"symfony/http-foundation": "~3.2",
"symfony/http-kernel": "~3.2",
Expand All @@ -42,11 +45,12 @@
"mockery/mockery": "~0.9",
"guzzlehttp/guzzle": "~6.3",
"geoip2/geoip2": "~2.1",
"phpunit/phpunit": "~6.3"
"phpunit/phpunit": "~9"
},
"autoload": {
"psr-4": {
"Cubex\\": "src/"
"Cubex\\": "src/",
"CubexTest\\": "tests/"
}
}
}
22 changes: 7 additions & 15 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
processIsolation="false"
stopOnFailure="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
>
<php>
<ini name="date.timezone" value="UTC"/>
</php>
Expand All @@ -19,14 +16,9 @@
<directory>./tests/Cubex</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">src</directory>
</whitelist>
<blacklist>
<directory suffix=".php">vendor</directory>
<directory suffix=".php">testing</directory>
<directory suffix=".php">tests</directory>
</blacklist>
</filter>
</include>
</coverage>
</phpunit>
8 changes: 4 additions & 4 deletions src/Cubex.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function prepareCubex()

foreach($files as $fileName)
{
$file = Path::build($this->getProjectRoot(), 'conf', $fileName);
$file = Path::system($this->getProjectRoot(), 'conf', $fileName);
try
{
$config->loadFile($file, true);
Expand Down Expand Up @@ -330,13 +330,13 @@ public function handle(
if($request->getRequestUri() === '/favicon.ico')
{
$favIconPaths = [];
$favIconPaths[] = Path::build($this->getProjectRoot(), 'favicon.ico');
$favIconPaths[] = Path::build(
$favIconPaths[] = Path::system($this->getProjectRoot(), 'favicon.ico');
$favIconPaths[] = Path::system(
$this->getProjectRoot(),
'assets',
'favicon.ico'
);
$favIconPaths[] = Path::build(dirname(__DIR__), 'favicon.ico');
$favIconPaths[] = Path::system(dirname(__DIR__), 'favicon.ico');
$favPath = null;

foreach($favIconPaths as $favPath)
Expand Down
8 changes: 4 additions & 4 deletions src/Kernel/CubexKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function findRoute(Request $request)
try
{
$route = $router->process(
Path::buildUnix($this->_pathProcessed, $path)
Path::url($this->_pathProcessed, $path)
);
$this->_pathProcessed = null;
}
Expand Down Expand Up @@ -296,7 +296,7 @@ public function autoRoute(Request $request, $pathParts)
foreach($subRoutes as $subRoute)
{
//Half sprintf style, but changed to str_replace for multiple instances
$attempt = Path::buildWindows(
$attempt = Path::windows(
$namespace,
str_replace('%s', $classPath, $subRoute)
);
Expand Down Expand Up @@ -351,7 +351,7 @@ public function executeRoute(
if(stripos($value, '\\') !== false && preg_match($match, $value))
{
$class = $value;
$nsClass = Path::buildWindows(Objects::getNamespace($this), $value);
$nsClass = Path::windows(Objects::getNamespace($this), $value);

try
{
Expand Down Expand Up @@ -409,7 +409,7 @@ public function executeRoute(

if($value instanceof CubexKernel)
{
$value->_pathProcessed = Path::buildUnix(
$value->_pathProcessed = Path::url(
$this->_pathProcessed,
$route->getMatchedPath()
);
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function _processRoutes($url, $routes)
{
return $this->createRoute(
$subMatch->getValue(),
Path::buildUnix($matchedPath, $subMatch->getMatchedPath())
Path::url($matchedPath, $subMatch->getMatchedPath())
);
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/CubexTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function assertResponseContains($expect, TestResponse $response = null)
{
$response = $this->_lastResponse;
}
$this->assertContains($expect, $response->getContent());
$this->assertStringContainsString($expect, $response->getContent());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/View/ViewModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ protected function _calculateTemplateDefaults()
$this->_templateDir = dirname($this->_templateDir);
}

$this->_templateDir = Path::build(
$this->_templateDir = Path::system(
$this->_templateDir,
$this->_templateDirName
);

if($this->_templateFile === null)
{
$this->_templateFile = Path::buildCustom(
$this->_templateFile = Path::custom(
DIRECTORY_SEPARATOR,
array_reverse($nesting)
);
Expand All @@ -155,7 +155,7 @@ protected function _calculateTemplateDefaults()
*/
public function getTemplatePath($extension = '.phtml')
{
return Path::build(
return Path::system(
$this->getTemplateDir(),
$this->getTemplateFile()
) . $extension;
Expand Down
4 changes: 2 additions & 2 deletions tests/Cubex/Console/Commands/BuiltInWebServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public function testCommand(array $options, $passthru, $negate = false)
$bufferOut = $this->getCommandOutput($command, $options);
if($negate)
{
$this->assertNotContains($passthru, $bufferOut);
$this->assertStringNotContainsString($passthru, $bufferOut);
}
else
{
$this->assertContains($passthru, $bufferOut);
$this->assertStringContainsString($passthru, $bufferOut);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Cubex/Console/ConsoleCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testClassDocBlocks()
public function testOutput()
{
$command = new TestConsoleCommand();
$this->assertContains(
$this->assertStringContainsString(
'First: Brooke
Last: Bryan
Middle(s): Anthony James',
Expand All @@ -65,7 +65,7 @@ public function testOutput()
public function testOutputProcess()
{
$command = new TestProcessConsoleCommand();
$this->assertContains(
$this->assertStringContainsString(
'First: Brooke
Last: Bryan
Middle(s): Anthony James',
Expand Down
6 changes: 3 additions & 3 deletions tests/Cubex/Console/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function testDoRun()
$console->doRun($input, $output);
$buffered = $output->fetch();

$this->assertContains('phpserver', $buffered);
$this->assertContains('Namer', $buffered);
$this->assertContains(
$this->assertStringContainsString('phpserver', $buffered);
$this->assertStringContainsString('Namer', $buffered);
$this->assertStringContainsString(
'Command [broken] does not reference a valid class',
$buffered
);
Expand Down
24 changes: 12 additions & 12 deletions tests/Cubex/CubexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public function testExceptions()
$exception = new \Exception("Test Exception", 345);
$resp = $cubex->exceptionResponse($exception);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $resp);
$this->assertContains('An uncaught exception was thrown', (string)$resp);
$this->assertContains('Test Exception', (string)$resp);
$this->assertContains('345', (string)$resp);
$this->assertStringContainsString('An uncaught exception was thrown', (string)$resp);
$this->assertStringContainsString('Test Exception', (string)$resp);
$this->assertStringContainsString('345', (string)$resp);

$exception = CubexException::debugException("msg", 123, 'solution');
$resp = $cubex->exceptionResponse($exception);
$this->assertContains('msg', (string)$resp);
$this->assertContains('123', (string)$resp);
$this->assertContains('solution', (string)$resp);
$this->assertStringContainsString('msg', (string)$resp);
$this->assertStringContainsString('123', (string)$resp);
$this->assertStringContainsString('solution', (string)$resp);
}

public function testHandle()
Expand Down Expand Up @@ -113,8 +113,8 @@ public function testInvalidRequest()
$cubex = $this->sampleProjectCubex();

$resp = $cubex->handle($request);
$this->assertContains('An uncaught exception was thrown', (string)$resp);
$this->assertContains('You must use a \Cubex\Http\Request', (string)$resp);
$this->assertStringContainsString('An uncaught exception was thrown', (string)$resp);
$this->assertStringContainsString('You must use a \Cubex\Http\Request', (string)$resp);

$this->expectException(
'\InvalidArgumentException',
Expand All @@ -128,8 +128,8 @@ public function testInvalidRequest()

$resp = $cubex->handle($request);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $resp);
$this->assertContains('Uncaught Exception', (string)$resp);
$this->assertContains('You must use a \Cubex\Http\Request', (string)$resp);
$this->assertStringContainsString('Uncaught Exception', (string)$resp);
$this->assertStringContainsString('You must use a \Cubex\Http\Request', (string)$resp);
}

public function testTerminate()
Expand Down Expand Up @@ -241,12 +241,12 @@ public function testExceptionAsString(\Exception $e, $contains)
{
foreach($contains as $contain)
{
$this->assertContains($contain, Cubex::exceptionAsString($e));
$this->assertStringContainsString($contain, Cubex::exceptionAsString($e));
}
}
else
{
$this->assertContains($contains, Cubex::exceptionAsString($e));
$this->assertStringContainsString($contains, Cubex::exceptionAsString($e));
}
}

Expand Down
Loading