Skip to content

Commit

Permalink
minor: add test for fallback dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Nov 27, 2024
1 parent 5e125cf commit 0b99357
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</testsuite>
<testsuite name="Functional tests">
<directory suffix=".phpt">tests/functional/error-handler/</directory>
<file>tests/functional/fallback-dirs/test.phpt</file>
<file>tests/functional/invalid-class/test.phpt</file>
<file>tests/functional/nested-composer-projects/test.phpt</file>
<file>tests/issue-13/test.phpt</file>
Expand Down
15 changes: 15 additions & 0 deletions tests/functional/fallback-dirs/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"repositories": [
{
"type": "vcs",
"url": "../../.."
}
],
"autoload": {
"Kcs\\ClassFinder\\FunctionalTests\\": "src/"
},
"require": {
"kcs/class-finder": "dev-master",
"symfony/string": "*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\String;

class LazyString implements \Stringable, \JsonSerializable
{

public function __toString(): string
{
return 'test';
}

public function jsonSerialize(): mixed
{
return [];
}
}
9 changes: 9 additions & 0 deletions tests/functional/fallback-dirs/src/Foobar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace Kcs\ClassFinder\FunctionalTests;

class Foobar
{
}
17 changes: 17 additions & 0 deletions tests/functional/fallback-dirs/test.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Fallback directories
--INI--
error_reporting=E_ALL & ~E_NOTICE & ~E_DEPRECATED
--FILE--
<?php
require_once __DIR__ . '/vendor/autoload.php';

$finder = (new Kcs\ClassFinder\Finder\ComposerFinder())->skipBogonFiles();
$arr = iterator_to_array($finder);

/** @var ReflectionClass $class */
$class = $arr[\Symfony\Component\String\LazyString::class];
echo str_replace(DIRECTORY_SEPARATOR, '/', $class->getFileName());
?>
--EXPECTF--
%s/tests/functional/fallback-dirs/vendor/symfony/string/LazyString.php

0 comments on commit 0b99357

Please sign in to comment.