Skip to content

Commit

Permalink
Merge pull request #72 from JayBizzle/laravel_8
Browse files Browse the repository at this point in the history
Support Laravel 8 and PHPUnit 9 updates
  • Loading branch information
ytake authored Oct 27, 2020
2 parents 57ada19 + 78081f8 commit 39dbe7a
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 41 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sudo: false
language: php
php:
- 7.2
- 7.3
- 7.4
services:
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@
],
"license": "MIT",
"require": {
"php": ">=7.2",
"illuminate/support": "^6.0|^7.0",
"illuminate/view": "^6.0|^7.0",
"illuminate/config": "^6.0|^7.0",
"illuminate/console": "^6.0|^7.0",
"illuminate/events": "^6.0|^7.0",
"php": "^7.3",
"illuminate/support": "^8.0",
"illuminate/view": "^8.0",
"illuminate/config": "^8.0",
"illuminate/console": "^8.0",
"illuminate/events": "^8.0",
"smarty/smarty": "^3.1.33"
},
"require-dev": {
"predis/predis": "^1.0",
"symfony/framework-bundle": "^4.0|^5.0",
"symfony/console": "^4.0|^5.0",
"phpunit/phpunit": "^8.5",
"symfony/framework-bundle": "^5.0",
"symfony/console": "^5.0",
"phpunit/phpunit": "^9.0",
"satooshi/php-coveralls": "*",
"phpmd/phpmd": "@stable",
"squizlabs/php_codesniffer": "^3.4.2",
"friendsofphp/php-cs-fixer": "^2.15.3",
"sebastian/phpcpd": "*",
"phploc/phploc": "*",
"pdepend/pdepend" : "^2.5.2",
"sensiolabs/security-checker": "^5.0|^6.0"
"sensiolabs/security-checker": "^6.0"
},
"suggest": {
"ext-memcached": "memcached Template Cache Driver",
Expand Down
6 changes: 3 additions & 3 deletions tests/ConfigureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ protected function setUp(): void
parent::setUp();
$filesystem = new \Illuminate\Filesystem\Filesystem;

$items = $filesystem->getRequire(__DIR__ . '/config/config.php');
$items = $filesystem->getRequire(__DIR__.'/config/config.php');
$this->config->set('ytake-laravel-smarty', $items);
}

public function testHasConfigure(): void
{
$this->assertInternalType('array', $this->config->all());
$this->assertIsArray($this->config->all());
$config = $this->config->get('ytake-laravel-smarty');
$this->assertInternalType('array', $config);
$this->assertIsArray($config);
$this->assertArrayHasKey('extension', $config);
$this->assertArrayHasKey('debugging', $config);
$this->assertArrayHasKey('caching', $config);
Expand Down
10 changes: 5 additions & 5 deletions tests/Console/CacheClearCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected function setUp(): void
}
public function testInstance(): void
{
$this->assertInstanceOf("Ytake\\LaravelSmarty\\Console\\CacheClearCommand", $this->command);
$this->assertInstanceOf('Ytake\\LaravelSmarty\\Console\\CacheClearCommand', $this->command);
}

public function testCommand(): void
Expand All @@ -30,7 +30,7 @@ public function testCommand(): void
$output
);
$this->assertSame('ytake:smarty-clear-cache', $this->command->getName());
$this->assertSame("Flush the Smarty cache.", $this->command->getDescription());
$this->assertSame('Flush the Smarty cache.', $this->command->getDescription());
$this->assertSame('Smarty cache cleared!', trim($output->fetch()));
}

Expand All @@ -45,8 +45,8 @@ public function testCommandFile(): void
$fileCount = 0;
$pathName = null;
foreach ($dir as $file) {
if(!$file->isDot()) {
if($file->getFilename() != '.gitignore') {
if (! $file->isDot()) {
if ($file->getFilename() != '.gitignore') {
$pathName = $file->getPathname();
$fileCount++;
}
Expand All @@ -58,7 +58,7 @@ public function testCommandFile(): void
new \Symfony\Component\Console\Input\ArrayInput(['--file' => 'test.tpl']),
$output
);
$this->assertFileNotExists($pathName);
$this->assertFileDoesNotExist($pathName);
$this->assertSame('Specified file was cache cleared!', trim($output->fetch()));
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Console/CompiledClearCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function setUp(): void

public function testInstance(): void
{
$this->assertInstanceOf("Ytake\\LaravelSmarty\\Console\\ClearCompiledCommand", $this->command);
$this->assertInstanceOf('Ytake\\LaravelSmarty\\Console\\ClearCompiledCommand', $this->command);
}

public function testCommand(): void
Expand All @@ -25,7 +25,7 @@ public function testCommand(): void
new \Symfony\Component\Console\Input\ArrayInput([]),
new \Symfony\Component\Console\Output\NullOutput
);
$this->assertSame("Remove the compiled Smarty files.", $this->command->getDescription());
$this->assertSame('Remove the compiled Smarty files.', $this->command->getDescription());
$this->assertNotNull($this->command->getSynopsis());
}

Expand All @@ -40,7 +40,7 @@ public function testClearCompile(): void
$fileCount = 0;
$pathName = null;
foreach ($dir as $file) {
if (!$file->isDot()) {
if (! $file->isDot()) {
if ($file->getFilename() != '.gitignore') {
$pathName = $file->getPathname();
$fileCount++;
Expand All @@ -53,7 +53,7 @@ public function testClearCompile(): void
new \Symfony\Component\Console\Input\ArrayInput([]),
$output
);
$this->assertFileNotExists($pathName);
$this->assertFileDoesNotExist($pathName);
$this->assertSame('Removed 1 compiled Smarty file.', trim($output->fetch()));
}

Expand Down
9 changes: 4 additions & 5 deletions tests/SmartyComposerTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Class SmartyComposerTest
* Class SmartyComposerTest.
*/
class SmartyComposerTest extends SmartyTestCase
{
Expand All @@ -10,7 +10,7 @@ public function testShouldDispatchViewComposerCaseAlwaysCompile(): void
$this->factory->composer('include', function (\Illuminate\View\View $view) {
$view->with('value', 'dispatch view composer');
});
$this->assertContains('dispatch view composer', $this->factory->make('include_test')->render());
$this->assertStringContainsString('dispatch view composer', $this->factory->make('include_test')->render());
}

public function testShouldDispatchViewComposerCaseOnceCompile(): void
Expand All @@ -24,11 +24,10 @@ public function testShouldDispatchViewComposerCaseOnceCompile(): void
$view->with('creator', 'dispatch view creator');
});
$view = $this->factory->make('include_test')->render();
$this->assertContains('dispatch view composer', $view);
$this->assertContains('dispatch view creator', $view);
$this->assertStringContainsString('dispatch view composer', $view);
$this->assertStringContainsString('dispatch view creator', $view);
}


public function tearDown(): void
{
$smartyExtension = $this->factory->getSmarty()->ext;
Expand Down
6 changes: 2 additions & 4 deletions tests/SmartyEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function setUp(): void

public function testInstance(): void
{
$this->assertInstanceOf("Ytake\\LaravelSmarty\\Engines\\SmartyEngine", $this->engine);
$this->assertInstanceOf('Ytake\\LaravelSmarty\\Engines\\SmartyEngine', $this->engine);
}

public function testShouldReturnSameValue(): void
Expand All @@ -24,11 +24,9 @@ public function testShouldReturnSameValue(): void
$this->assertSame('helloSmarty', $this->engine->get('test.tpl', ['value' => 'Smarty']));
}

/**
* @expectedException \SmartyException
*/
public function testException(): void
{
$this->expectException(\SmartyException::class);
$this->engine->get('testing.tpl');
}
}
18 changes: 9 additions & 9 deletions tests/SmartyFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,26 @@ class SmartyManagerFactory extends SmartyTestCase
{
public function testInstance(): void
{
$this->assertInstanceOf("Ytake\\LaravelSmarty\\SmartyFactory", $this->factory);
$this->assertInstanceOf('Ytake\\LaravelSmarty\\SmartyFactory', $this->factory);
}

public function testSmarty(): void
{
$this->assertInstanceOf("Smarty", $this->factory->getSmarty());
$this->assertInstanceOf('Smarty', $this->factory->getSmarty());
$this->assertNotTrue($this->factory->getVersion());
}

public function testConfigure(): void
{
$smarty = $this->factory->getSmarty();
foreach($smarty->getTemplateDir() as $dir) {
foreach ($smarty->getTemplateDir() as $dir) {
$this->assertSame(true, file_exists($dir));
}
}

/**
* @expectedException \Ytake\LaravelSmarty\Exception\MethodNotFoundException
*/
public function testUndefinedFunction(): void
{
$this->expectException(\Ytake\LaravelSmarty\Exception\MethodNotFoundException::class);
$this->factory->hello();
$this->factory->assing();
$this->factory->smarty([1 => 2]);
Expand Down Expand Up @@ -55,19 +53,21 @@ protected function getProtectMethod($class, $name)
$class = new \ReflectionClass($class);
$method = $class->getMethod($name);
$method->setAccessible(true);

return $method;
}

public function scan()
{
$files = [];
$dir = opendir(__DIR__ . '/storage/smarty/compile');
while($file = readdir($dir)) {
if($file != '.' && $file != '..' && $file != '.gitignore') {
$dir = opendir(__DIR__.'/storage/smarty/compile');
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..' && $file != '.gitignore') {
$files[] = $file;
}
}
closedir($dir);

return $files;
}
}

0 comments on commit 39dbe7a

Please sign in to comment.