Skip to content

Commit

Permalink
Adding Robo Test fixtures
Browse files Browse the repository at this point in the history
Adding first test for JoRobo
Adding phpstan dependency and configuration
  • Loading branch information
Hackwar committed May 15, 2023
1 parent 647fa6a commit c1e6f5b
Show file tree
Hide file tree
Showing 16 changed files with 835 additions and 18 deletions.
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@
}
},
"autoload": {
"psr-4": {"Joomla\\Jorobo\\": "src"}
"psr-4": {
"Joomla\\Jorobo\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Joomla\\Jorobo\\": "src",
"Robo\\": "tests/src"
}
},

"require" : {
"php": ">=7.2.5|~8",
"consolidation/robo": "~3",
Expand All @@ -37,6 +46,8 @@
"squizlabs/php_codesniffer": "~3.7.2",
"friendsofphp/php-cs-fixer": "^3.4",
"phan/phan": "^5.4",
"phpunit/phpunit": "^8.5"
"phpunit/phpunit": "^8.5",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1"
}
}
112 changes: 111 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
parameters:
level: 1
paths:
- src
excludePaths:
ignoreErrors:
reportUnmatchedIgnoredErrors: false
15 changes: 0 additions & 15 deletions tests/RoboFileTest.php

This file was deleted.

5 changes: 5 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
if (!defined('JPATH_BASE')) {
define('JPATH_BASE', dirname(__DIR__));
}

86 changes: 86 additions & 0 deletions tests/src/Fixtures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Robo;

use Symfony\Component\Filesystem\Filesystem;

class Fixtures
{
protected $testDir;
protected $tmpDirs = [];
protected $clonedRepos = [];

/**
* Fixtures constructor
*/
public function __construct()
{
$testDir = false;
}

/**
* Clean up any temporary directories that may have been created
*/
public function cleanup()
{
$fs = new Filesystem();
foreach ($this->tmpDirs as $tmpDir) {
try {
$fs->remove($tmpDir);
}
catch (\Exception $e) {
// Ignore problems with removing fixtures.
}
}
$this->tmpDirs = [];
}

/**
* Create a new temporary directory.
*
* @param string|bool $basedir Where to store the temporary directory
* @return type
*/
public function mktmpdir($basedir = false)
{
$tempfile = tempnam($basedir ?: $this->testDir ?: sys_get_temp_dir(),'robo-tests');
unlink($tempfile);
mkdir($tempfile);
$this->tmpDirs[] = $tempfile;
return $tempfile;
}

public function createAndCdToSandbox()
{
$sourceSandbox = $this->sandboxDir();
$targetSandbox = $this->mktmpdir();
$fs = new Filesystem();
$fs->mirror($sourceSandbox, $targetSandbox);
chdir($targetSandbox);

return $targetSandbox;
}

public function dataFile($filename)
{
return $this->fixturesDir() . '/' . $filename;
}

protected function fixturesDir()
{
return dirname(__DIR__) . '/_data';
}

protected function sandboxDir()
{
return $this->fixturesDir() . '/claypit';
}

protected function testDir()
{
if (!$this->testDir) {
$this->testDir = $this->mktmpdir();
}
return $this->testDir;
}
}
Loading

0 comments on commit c1e6f5b

Please sign in to comment.