diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 86821fe..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,54 +0,0 @@ -defaults: &defaults - steps: - # common php steps - - run: echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories - - run: if [ -n "$ADD_PACKAGES" ]; then apk -U add $ADD_PACKAGES; fi; - - run: if [ -n "$ADD_MODULES" ]; then docker-php-ext-install $ADD_MODULES; fi; - - run: echo "date.timezone = UTC" >> $(php --ini |grep Scan |awk '{print $NF}')/timezone.ini - - run: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer - - # pre-checkout steps - - # checkout - - checkout - - # post-checkout steps - - # run tests - - run: composer install -n --prefer-dist - - run: php vendor/phpunit/phpunit/phpunit -c phpunit.xml --log-junit /tmp/test-results/phpunit/junit.xml - - store_test_results: - path: /tmp/test-results - -version: 2 -jobs: - build-php70: - <<: *defaults - docker: - - image: php:7.0-alpine - build-php71: - <<: *defaults - docker: - - image: php:7.1-alpine - build-php72: - <<: *defaults - docker: - - image: php:7.2-alpine - build-php73: - <<: *defaults - docker: - - image: php:7.3-alpine - build-php74: - <<: *defaults - docker: - - image: php:7.4-alpine - -workflows: - version: 2 - build: - jobs: - - build-php70 - - build-php71 - - build-php72 - - build-php73 - - build-php74 diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..0e11ae6 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -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}%)" diff --git a/composer.json b/composer.json index bcad6dc..421154f 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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", @@ -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/" } } } diff --git a/phpunit.xml b/phpunit.xml index dedaee6..ce803bd 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,16 +1,13 @@ - +> @@ -19,14 +16,9 @@ ./tests/Cubex - - + + src - - - vendor - testing - tests - - + + diff --git a/src/Cubex.php b/src/Cubex.php index cc6437e..623b1aa 100644 --- a/src/Cubex.php +++ b/src/Cubex.php @@ -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); @@ -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) diff --git a/src/Kernel/CubexKernel.php b/src/Kernel/CubexKernel.php index 2a92a72..8526f77 100644 --- a/src/Kernel/CubexKernel.php +++ b/src/Kernel/CubexKernel.php @@ -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; } @@ -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) ); @@ -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 { @@ -409,7 +409,7 @@ public function executeRoute( if($value instanceof CubexKernel) { - $value->_pathProcessed = Path::buildUnix( + $value->_pathProcessed = Path::url( $this->_pathProcessed, $route->getMatchedPath() ); diff --git a/src/Routing/Router.php b/src/Routing/Router.php index caa04de..bf2e7d7 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -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; diff --git a/src/Testing/CubexTestCase.php b/src/Testing/CubexTestCase.php index 9aee531..2b7f94b 100644 --- a/src/Testing/CubexTestCase.php +++ b/src/Testing/CubexTestCase.php @@ -142,7 +142,7 @@ public function assertResponseContains($expect, TestResponse $response = null) { $response = $this->_lastResponse; } - $this->assertContains($expect, $response->getContent()); + $this->assertStringContainsString($expect, $response->getContent()); } /** diff --git a/src/View/ViewModel.php b/src/View/ViewModel.php index b67395f..cda3ca4 100644 --- a/src/View/ViewModel.php +++ b/src/View/ViewModel.php @@ -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) ); @@ -155,7 +155,7 @@ protected function _calculateTemplateDefaults() */ public function getTemplatePath($extension = '.phtml') { - return Path::build( + return Path::system( $this->getTemplateDir(), $this->getTemplateFile() ) . $extension; diff --git a/tests/Cubex/Console/Commands/BuiltInWebServerTest.php b/tests/Cubex/Console/Commands/BuiltInWebServerTest.php index 22567a6..32de076 100644 --- a/tests/Cubex/Console/Commands/BuiltInWebServerTest.php +++ b/tests/Cubex/Console/Commands/BuiltInWebServerTest.php @@ -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); } } diff --git a/tests/Cubex/Console/ConsoleCommandTest.php b/tests/Cubex/Console/ConsoleCommandTest.php index 8993bc0..29ce382 100644 --- a/tests/Cubex/Console/ConsoleCommandTest.php +++ b/tests/Cubex/Console/ConsoleCommandTest.php @@ -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', @@ -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', diff --git a/tests/Cubex/Console/ConsoleTest.php b/tests/Cubex/Console/ConsoleTest.php index afc63b8..91e66f1 100644 --- a/tests/Cubex/Console/ConsoleTest.php +++ b/tests/Cubex/Console/ConsoleTest.php @@ -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 ); diff --git a/tests/Cubex/CubexTest.php b/tests/Cubex/CubexTest.php index 10cb147..ce5a030 100644 --- a/tests/Cubex/CubexTest.php +++ b/tests/Cubex/CubexTest.php @@ -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() @@ -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', @@ -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() @@ -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)); } } diff --git a/tests/Cubex/Http/ResponseTest.php b/tests/Cubex/Http/ResponseTest.php index 7c15061..9661401 100644 --- a/tests/Cubex/Http/ResponseTest.php +++ b/tests/Cubex/Http/ResponseTest.php @@ -21,19 +21,19 @@ public function testSend() { $response = new Response(); $responseSend = $response->send(); - $this->assertObjectHasAttribute('headers', $responseSend); - $this->assertObjectHasAttribute('content', $responseSend); - $this->assertObjectHasAttribute('version', $responseSend); - $this->assertObjectHasAttribute('statusCode', $responseSend); - $this->assertObjectHasAttribute('statusText', $responseSend); - $this->assertObjectHasAttribute('charset', $responseSend); + $this->assertTrue(property_exists($responseSend, 'headers')); + $this->assertTrue(property_exists($responseSend, 'content')); + $this->assertTrue(property_exists($responseSend, 'version')); + $this->assertTrue(property_exists($responseSend, 'statusCode')); + $this->assertTrue(property_exists($responseSend, 'statusText')); + $this->assertTrue(property_exists($responseSend, 'charset')); } public function testFromText() { $response = new Response(); $response->fromText("Hello World"); - $this->assertContains('Content-Type: text/plain', (string)$response); + $this->assertStringContainsString('Content-Type: text/plain', (string)$response); } public function testFromJson() @@ -57,7 +57,7 @@ public function testRenderable() $renderable = new RenderableClass(); $response = new Response(); $response->from($renderable); - $this->assertContains('rendered content', (string)$response); + $this->assertStringContainsString('rendered content', (string)$response); } public function testCubexHeaders() @@ -68,18 +68,18 @@ public function testCubexHeaders() } $response = new Response(); $response->setCubexHeaders(); - $this->assertContains('X-Execution-Time', (string)$response); + $this->assertStringContainsString('X-Execution-Time', (string)$response); $response = new Response(); $response->disableCubexHeaders(); $response->setCubexHeaders(); - $this->assertNotContains('X-Execution-Time', (string)$response); + $this->assertStringNotContainsString('X-Execution-Time', (string)$response); $response = new Response(); $response->disableCubexHeaders(); $response->enableCubexHeaders(); $response->setCubexHeaders(); - $this->assertContains('X-Execution-Time', (string)$response); + $this->assertStringContainsString('X-Execution-Time', (string)$response); } public function testCsvResponse() @@ -92,19 +92,16 @@ public function testCsvResponse() ); $response->setFilename('test.csv'); $raw = (string)$response->send(); - $this->assertContains('a1,b1,c1', $raw); + $this->assertStringContainsString('a1,b1,c1', $raw); } - /** - * @expectedException \Exception - * @expectedExceptionMessage You must specify an array or object when using a - * csv response - */ public function testInvalidCsvResponse() { $response = new CsvResponse(); $raw = (string)$response->getContent(); $this->assertEmpty($raw); + $this->expectException(\Exception::class); + $this->expectExceptionMessage('You must specify an array or object when using a csv response'); $response->setContent('this is a test'); } } diff --git a/tests/Cubex/Kernel/ApplicationKernelTest.php b/tests/Cubex/Kernel/ApplicationKernelTest.php index e74871c..7a58b54 100644 --- a/tests/Cubex/Kernel/ApplicationKernelTest.php +++ b/tests/Cubex/Kernel/ApplicationKernelTest.php @@ -9,6 +9,6 @@ class ApplicationKernelTest extends TestCase public function testSubRoutesRetunsArray() { $kernel = new ApplicationKernel(); - $this->assertInternalType('array', $kernel->subRouteTo()); + $this->assertIsArray($kernel->subRouteTo()); } } diff --git a/tests/Cubex/Kernel/ControllerKernelTest.php b/tests/Cubex/Kernel/ControllerKernelTest.php index 8b2991f..8768959 100644 --- a/tests/Cubex/Kernel/ControllerKernelTest.php +++ b/tests/Cubex/Kernel/ControllerKernelTest.php @@ -9,6 +9,6 @@ class ControllerKernelTest extends TestCase public function testSubRoutesRetunsArray() { $kernel = new ControllerKernel(); - $this->assertInternalType('array', $kernel->subRouteTo()); + $this->assertIsArray($kernel->subRouteTo()); } } diff --git a/tests/Cubex/Kernel/CubexKernelTest.php b/tests/Cubex/Kernel/CubexKernelTest.php index a5b70b3..83f6be7 100644 --- a/tests/Cubex/Kernel/CubexKernelTest.php +++ b/tests/Cubex/Kernel/CubexKernelTest.php @@ -197,7 +197,7 @@ public function testHandleWithException() '\Symfony\Component\HttpFoundation\Response', $resp ); - $this->assertContains("Mocked Exception", $resp->getContent()); + $this->assertStringContainsString("Mocked Exception", $resp->getContent()); } public function testHandleInvalidResponse() @@ -862,7 +862,7 @@ public function testCanProcess() HttpKernelInterface::MASTER_REQUEST, false ); - $this->assertContains( + $this->assertStringContainsString( 'Error 403 - Access Forbidden', $result->getContent() ); @@ -934,7 +934,7 @@ public function baseRoutesProvider() public function testRouteData() { $kernel = new RouteDataTest(); - $this->assertInternalType('array', $kernel->getRouteData()); + $this->assertIsArray($kernel->getRouteData()); $this->assertArrayHasKey('one', $kernel->getRouteData()); $this->assertCount(2, $kernel->getRouteData()); $this->assertNull($kernel->getRouteData('three')); diff --git a/tests/Cubex/Kernel/EndpointKernelTest.php b/tests/Cubex/Kernel/EndpointKernelTest.php index c71b37e..6c80ea8 100644 --- a/tests/Cubex/Kernel/EndpointKernelTest.php +++ b/tests/Cubex/Kernel/EndpointKernelTest.php @@ -23,14 +23,14 @@ public function testExceptions() $kernel = new MockEndpointKernel(); $kernel->setCubex($this->getCubex()); $result = $kernel->handle(Request::create('/error', 'GET', [])); - $this->assertContains('json', $result->headers->get('content-type')); + $this->assertStringContainsString('json', $result->headers->get('content-type')); $content = $result->getContent(); $this->assertJson($content); - $this->assertContains( + $this->assertStringContainsString( 'status":{"code":500,"message":"Something Failed"}', $content ); - $this->assertContains( + $this->assertStringContainsString( '"type":"\\\\Packaged\\\\Api\\\\Exceptions\\\\ApiException"', $content ); @@ -41,7 +41,7 @@ public function testResult() $kernel = new MockEndpointKernel(); $kernel->setCubex($this->getCubex()); $result = $kernel->handle(Request::create('/result', 'GET', [])); - $this->assertContains('json', $result->headers->get('content-type')); + $this->assertStringContainsString('json', $result->headers->get('content-type')); $this->assertEquals( '{"status":{"code":200,"message":""},' . '"type":"\CubexTest\Cubex\Kernel\MockEndpointResult"' diff --git a/tests/Cubex/Kernel/ProjectKernelTest.php b/tests/Cubex/Kernel/ProjectKernelTest.php index 4b6ef98..3af6b4a 100644 --- a/tests/Cubex/Kernel/ProjectKernelTest.php +++ b/tests/Cubex/Kernel/ProjectKernelTest.php @@ -9,6 +9,6 @@ class ProjectKernelTest extends TestCase public function testSubRoutesRetunsArray() { $kernel = new ProjectKernel(); - $this->assertInternalType('array', $kernel->subRouteTo()); + $this->assertIsArray($kernel->subRouteTo()); } } diff --git a/tests/Cubex/Kernel/SubdomainKernelTest.php b/tests/Cubex/Kernel/SubdomainKernelTest.php index 4d0ddf0..8ddb893 100644 --- a/tests/Cubex/Kernel/SubdomainKernelTest.php +++ b/tests/Cubex/Kernel/SubdomainKernelTest.php @@ -62,7 +62,7 @@ public function testMethodCalls($subdomain, $expect, $catch = true) if(is_scalar($expect)) { - $this->assertContains($expect, $response->getContent()); + $this->assertStringContainsString($expect, $response->getContent()); } else { @@ -99,7 +99,7 @@ public function testCanProcess() HttpKernelInterface::MASTER_REQUEST, false ); - $this->assertContains('Please Login', (string)$result); + $this->assertStringContainsString('Please Login', (string)$result); } } diff --git a/tests/Cubex/View/BrandedTemplateViewTest.php b/tests/Cubex/View/BrandedTemplateViewTest.php index 994fffe..cdc8594 100644 --- a/tests/Cubex/View/BrandedTemplateViewTest.php +++ b/tests/Cubex/View/BrandedTemplateViewTest.php @@ -43,31 +43,31 @@ public function testFullReplacement() { $request = $this->createRequest('www.replace.com'); $view = $this->prepareViewModel($request); - $this->assertContains('Replaced', $view->render()); + $this->assertStringContainsString('Replaced', $view->render()); } public function testBuildsRequestFromGlobals() { $view = $this->prepareViewModel(); - $this->assertContains('Default branded page', $view->render()); + $this->assertStringContainsString('Default branded page', $view->render()); } public function testPrePost() { $request = $this->createRequest('www.custom.com'); $view = $this->prepareViewModel($request); - $this->assertContains('Pre', $view->render()); - $this->assertContains('Default branded page', $view->render()); - $this->assertContains('Post', $view->render()); + $this->assertStringContainsString('Pre', $view->render()); + $this->assertStringContainsString('Default branded page', $view->render()); + $this->assertStringContainsString('Post', $view->render()); } public function testLanguage() { $request = $this->createRequest('www.custom.test', 'it'); $view = $this->prepareViewModel($request); - $this->assertContains('Pre', $view->render()); - $this->assertContains('Italian Version', $view->render()); - $this->assertContains('Post', $view->render()); + $this->assertStringContainsString('Pre', $view->render()); + $this->assertStringContainsString('Italian Version', $view->render()); + $this->assertStringContainsString('Post', $view->render()); } public function testException() diff --git a/tests/Cubex/View/LayoutControllerTest.php b/tests/Cubex/View/LayoutControllerTest.php index 8075040..c033e69 100644 --- a/tests/Cubex/View/LayoutControllerTest.php +++ b/tests/Cubex/View/LayoutControllerTest.php @@ -27,7 +27,7 @@ public function testBasics() $controller->setLayout($layout); $this->assertEquals($layout, $controller->layout()); $layout->insert('testing', new Renderable($output)); - $this->assertContains($output, (string)$controller); + $this->assertStringContainsString($output, (string)$controller); } public function testDisableLayout() @@ -62,7 +62,7 @@ public function testResponses($route, $expect) false ); - $this->assertContains($expect, $response->getContent()); + $this->assertStringContainsString($expect, $response->getContent()); } /** diff --git a/tests/Cubex/View/LayoutTest.php b/tests/Cubex/View/LayoutTest.php index d6abe78..c5e7a8f 100644 --- a/tests/Cubex/View/LayoutTest.php +++ b/tests/Cubex/View/LayoutTest.php @@ -40,8 +40,8 @@ public function testRender() $layout = new Layout(new CubexProject(), 'Default'); $layout->insert('testing', new RenderableSection()); $rendered = $layout->render(); - $this->assertContains('Testing', $rendered); - $this->assertContains('
section
', $rendered); + $this->assertStringContainsString('Testing', $rendered); + $this->assertStringContainsString('
section
', $rendered); } public function testSetCallingClass() @@ -50,8 +50,8 @@ public function testSetCallingClass() $layout->setCallingClass('namespaced\CubexProject'); $layout->insert('testing', new RenderableSection()); $rendered = $layout->render(); - $this->assertContains('Testing', $rendered); - $this->assertContains('
section
', $rendered); + $this->assertStringContainsString('Testing', $rendered); + $this->assertStringContainsString('
section
', $rendered); } public function testData() diff --git a/tests/Cubex/View/MustacheViewTest.php b/tests/Cubex/View/MustacheViewTest.php index c5b4d33..cbf37cc 100644 --- a/tests/Cubex/View/MustacheViewTest.php +++ b/tests/Cubex/View/MustacheViewTest.php @@ -11,7 +11,7 @@ public function testRender() $view = new TestMustacheModel(); $view->setTemplateDir(__DIR__ . DIRECTORY_SEPARATOR . 'res'); $view->setTemplateFile('mustache'); - $this->assertContains( + $this->assertStringContainsString( 'Hello Test You have just won $10 ($12)!', $view->render() ); diff --git a/tests/Cubex/View/TemplatedViewModelTest.php b/tests/Cubex/View/TemplatedViewModelTest.php index 10b8b38..a67f4ee 100644 --- a/tests/Cubex/View/TemplatedViewModelTest.php +++ b/tests/Cubex/View/TemplatedViewModelTest.php @@ -14,7 +14,7 @@ public function testRender() */ $view->setTemplateDir(__DIR__ . DIRECTORY_SEPARATOR . 'res'); $view->setTemplateFile('test'); - $this->assertContains('Test phtml file', $view->render()); + $this->assertStringContainsString('Test phtml file', $view->render()); $this->expectException('Exception', 'Excepted'); $view->setTemplateFile('exceptional'); diff --git a/tests/Cubex/View/ViewModelTest.php b/tests/Cubex/View/ViewModelTest.php index 12f81ea..0634286 100644 --- a/tests/Cubex/View/ViewModelTest.php +++ b/tests/Cubex/View/ViewModelTest.php @@ -23,7 +23,7 @@ public function testGetSet() $this->assertEquals('randomFile', $view->getTemplateFile()); $this->assertEquals( - Path::build('randomDir', 'randomFile.phtml'), + Path::system('randomDir', 'randomFile.phtml'), $view->getTemplatePath('.phtml') ); } @@ -59,7 +59,7 @@ public function testToString() $exception = 'Render Exception'; $viewModel = new RenderableViewModel($exception); $expect = '

An uncaught exception was thrown

'; - $this->assertContains($expect, (string)$viewModel); + $this->assertStringContainsString($expect, (string)$viewModel); } }