Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
automatic_updates
Commits
d64c9f30
Commit
d64c9f30
authored
2 years ago
by
Ted Bowman
Browse files
Options
Downloads
Patches
Plain Diff
Revert "start FixtureUtility.php"
This reverts commit
da6f5255
.
parent
e9f8a1c4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package_manager/tests/src/Kernel/FixtureUtility.php
+0
-81
0 additions, 81 deletions
package_manager/tests/src/Kernel/FixtureUtility.php
package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
+28
-1
28 additions, 1 deletion
...manager/tests/src/Kernel/PackageManagerKernelTestBase.php
with
28 additions
and
82 deletions
package_manager/tests/src/Kernel/FixtureUtility.php
deleted
100644 → 0
+
0
−
81
View file @
e9f8a1c4
<?php
namespace
Drupal\Tests\package_manager\Kernel
;
use
Symfony\Component\Filesystem\Filesystem
;
use
Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator
;
/**
* A utility for all things fixtures.
*/
class
FixtureUtility
{
/**
* If a fixture path has been set, mirrors it to the given path.
*
* @param string $source_path
* The source path.
* @param string $destination_path
* The path to which the fixture files should be mirrored.
*/
public
static
function
copyFixtureFilesTo
(
string
$source_path
,
string
$destination_path
):
void
{
(
new
Filesystem
())
->
mirror
(
$source_path
,
$destination_path
,
NULL
,
[
'override'
=>
TRUE
,
'delete'
=>
TRUE
,
]);
static
::
cleanUpFixtureFiles
(
$destination_path
);
}
/**
* Clean up fixture files.
*
* @param string $destination_path
* The destination path.
*/
private
static
function
cleanUpFixtureFiles
(
string
$destination_path
)
{
static
::
renameInfoYmlFiles
(
$destination_path
);
static
::
renameGitDirectories
(
$destination_path
);
}
/**
* Renames all files that end with .info.yml.hide.
*
* @param string $dir
* The directory to be iterated through.
*/
protected
static
function
renameInfoYmlFiles
(
string
$dir
)
{
// Construct the iterator.
$it
=
new
RecursiveDirectoryIterator
(
$dir
,
\RecursiveIteratorIterator
::
SELF_FIRST
);
// Loop through files and rename them.
foreach
(
new
\RecursiveIteratorIterator
(
$it
)
as
$file
)
{
if
(
$file
->
getExtension
()
==
'hide'
)
{
rename
(
$file
->
getPathname
(),
$dir
.
DIRECTORY_SEPARATOR
.
$file
->
getRelativePath
()
.
DIRECTORY_SEPARATOR
.
str_replace
(
".hide"
,
""
,
$file
->
getFilename
()));
}
}
}
/**
* Renames _git directories to .git.
*
* @param string $dir
* The directory to be iterated through.
*/
private
static
function
renameGitDirectories
(
string
$dir
)
{
// Construct the iterator.
$it
=
new
\DirectoryIterator
(
$dir
);
// Loop through files and rename them.
/** @var \Symfony\Component\Finder\SplFileInfo $file */
foreach
(
$it
as
$file
)
{
if
(
$file
->
isDir
()
&&
$file
->
getFilename
()
===
'_git'
)
{
rename
(
$file
->
getPathname
(),
$file
->
getPath
()
.
DIRECTORY_SEPARATOR
.
'.git'
);
}
}
}
}
This diff is collapsed.
Click to expand it.
package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
+
28
−
1
View file @
d64c9f30
...
...
@@ -19,6 +19,9 @@ use GuzzleHttp\HandlerStack;
use
GuzzleHttp\Psr7\Response
;
use
GuzzleHttp\Psr7\Utils
;
use
org\bovigo\vfs\vfsStream
;
use
org\bovigo\vfs\vfsStreamDirectory
;
use
org\bovigo\vfs\vfsStreamFile
;
use
org\bovigo\vfs\visitor\vfsStreamAbstractVisitor
;
use
PhpTuf\ComposerStager\Domain\Value\Path\PathInterface
;
use
PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface
;
use
PhpTuf\ComposerStager\Infrastructure\Value\Path\AbstractPath
;
...
...
@@ -215,7 +218,31 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase {
// Create the active directory and copy its contents from a fixture.
$active_dir
=
vfsStream
::
newDirectory
(
'active'
);
$this
->
vfsRoot
->
addChild
(
$active_dir
);
FixtureUtility
::
copyFixtureFilesTo
(
$source_dir
,
$active_dir
->
url
());
vfsStream
::
copyFromFileSystem
(
$source_dir
,
$active_dir
);
// Because we can't commit physical `.git` directories into the fixture, use
// a visitor to traverse the virtual file system and rename all `_git`
// directories to `.git`.
vfsStream
::
inspect
(
new
class
()
extends
vfsStreamAbstractVisitor
{
/**
* {@inheritdoc}
*/
public
function
visitFile
(
vfsStreamFile
$file
)
{}
/**
* {@inheritdoc}
*/
public
function
visitDirectory
(
vfsStreamDirectory
$dir
)
{
if
(
$dir
->
getName
()
===
'_git'
)
{
$dir
->
rename
(
'.git'
);
}
foreach
(
$dir
->
getChildren
()
as
$child
)
{
$this
->
visit
(
$child
);
}
}
});
// Create a staging root directory alongside the active directory.
$stage_dir
=
vfsStream
::
newDirectory
(
'stage'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment