Skip to content

Commit

Permalink
Merge Pr 67 (#68)
Browse files Browse the repository at this point in the history
* Add support/funding sections

* Rename abstract test class to avoid PHPUnit warning

---------

Co-authored-by: Michiel Rook <[email protected]>
  • Loading branch information
kayw-geek and mrook authored Nov 15, 2023
1 parent e9ffc96 commit 12fc9fe
Show file tree
Hide file tree
Showing 27 changed files with 101 additions and 48 deletions.
2 changes: 2 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
ComposerJsonSection::HOMEPAGE,
ComposerJsonSection::LICENSE,
ComposerJsonSection::AUTHORS,
ComposerJsonSection::SUPPORT,
ComposerJsonSection::FUNDING,
ComposerJsonSection::BIN,
ComposerJsonSection::REQUIRE,
ComposerJsonSection::REQUIRE_DEV,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
"require": {
"php": ">=7.3"
},
"support": {
"email": "[email protected]",
"irc": "irc://irc.freenode.org/example"
},
"funding": [
{
"type": "example",
"url": "https://www.patreon.com/example"
}
],
"require-dev": {
"phpunit/phpunit": "^8.5|^9.4"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace Symplify\MonorepoBuilder\Tests\Merge\Application;

use Symplify\MonorepoBuilder\Merge\Application\MergedAndDecoratedComposerJsonFactory;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;
use Symplify\SmartFileSystem\SmartFileInfo;

final class MergedAndDecoratedComposerJsonFactoryTest extends AbstractComposerJsonDecoratorTest
final class MergedAndDecoratedComposerJsonFactory extends AbstractComposerJsonDecorator
{
private MergedAndDecoratedComposerJsonFactory $mergedAndDecoratedComposerJsonFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Symplify\PackageBuilder\Testing\AbstractKernelTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;

abstract class AbstractComposerJsonDecoratorTest extends AbstractKernelTestCase
abstract class AbstractComposerJsonDecorator extends AbstractKernelTestCase
{
protected ComposerJsonFactory $composerJsonFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Symplify\MonorepoBuilder\ComposerJsonManipulator\ComposerJsonFactory;
use Symplify\MonorepoBuilder\Kernel\MonorepoBuilderKernel;
use Symplify\MonorepoBuilder\Merge\ComposerJsonDecorator\AppenderComposerJsonDecorator;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;

final class AppenderComposerJsonDecoratorTest extends AbstractComposerJsonDecoratorTest
final class AppenderComposerJsonDecorator extends AbstractComposerJsonDecorator
{
private AppenderComposerJsonDecorator $appenderComposerJsonDecorator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
use Symplify\MonorepoBuilder\ComposerJsonManipulator\ValueObject\ComposerJsonSection;
use Symplify\MonorepoBuilder\Kernel\MonorepoBuilderKernel;
use Symplify\MonorepoBuilder\Merge\ComposerJsonDecorator\RemoverComposerJsonDecorator;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;
use Symplify\MonorepoBuilder\ValueObject\Option;
use Symplify\PackageBuilder\Parameter\ParameterProvider;

final class RemoverComposerJsonDecoratorTest extends AbstractComposerJsonDecoratorTest
final class RemoverComposerJsonDecorator extends AbstractComposerJsonDecorator
{
/**
* @var mixed[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Symplify\MonorepoBuilder\ComposerJsonManipulator\ValueObject\ComposerJsonSection;
use Symplify\MonorepoBuilder\Kernel\MonorepoBuilderKernel;
use Symplify\MonorepoBuilder\Merge\ComposerJsonDecorator\RepositoryPathComposerJsonDecorator;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;

final class RepositoryPathComposerJsonDecoratorTest extends AbstractComposerJsonDecoratorTest
final class RepositoryPathComposerJsonDecorator extends AbstractComposerJsonDecorator
{
/**
* @var mixed[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

use Symplify\MonorepoBuilder\Kernel\MonorepoBuilderKernel;
use Symplify\MonorepoBuilder\Merge\ComposerJsonMerger;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;

/**
* @see \Symplify\MonorepoBuilder\Merge\ComposerJsonDecorator\RootRemoveComposerJsonDecorator
*/
final class RootRemoveComposerJsonDecoratorTest extends AbstractComposerJsonDecoratorTest
final class RootRemoveComposerJsonDecorator extends AbstractComposerJsonDecorator
{
private ComposerJsonMerger $composerJsonMerger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
use Iterator;
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
use Symplify\MonorepoBuilder\Merge\ComposerJsonMerger;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;
use Symplify\SmartFileSystem\SmartFileInfo;

final class ComposerJsonMergerTest extends AbstractComposerJsonDecoratorTest
final class ComposerJsonMerger extends AbstractComposerJsonDecorator
{
private ComposerJsonMerger $composerJsonMerger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use PHPUnit\Framework\Attributes\DataProvider;
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
use Symplify\MonorepoBuilder\Merge\ComposerKeyMerger\MinimalStabilityKeyMerger;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;
use Symplify\SmartFileSystem\SmartFileInfo;

/**
* @coversDefaultClass \Symplify\MonorepoBuilder\Merge\ComposerKeyMerger\MinimalStabilityKeyMerger
*/
final class MinimalStabilityKeyMergerTest extends AbstractComposerJsonDecoratorTest
final class MinimalStabilityKeyMerger extends AbstractComposerJsonDecorator
{
#[DataProvider('provideData')]
public function testFixture(SmartFileInfo $fixtureFileInfo): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
use Symfony\Component\Finder\Finder;
use Symplify\MonorepoBuilder\ComposerJsonManipulator\ValueObject\ComposerJson;
use Symplify\MonorepoBuilder\Merge\ComposerJsonMerger;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
use Symplify\SmartFileSystem\SmartFileInfo;

abstract class AbstractMergeTestCase extends AbstractComposerJsonDecoratorTest
abstract class AbstractMergeCase extends AbstractComposerJsonDecorator
{
private ComposerJsonMerger $composerJsonMerger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Symplify\MonorepoBuilder\Tests\Merge\Package\CombineStringsToArrayJsonMerger;

use Symplify\MonorepoBuilder\Tests\Merge\Package\AbstractMergeTestCase;
use Symplify\MonorepoBuilder\Tests\Merge\Package\AbstractMergeCase;

final class CombineStringsToArrayJsonMergerTest extends AbstractMergeTestCase
final class CombineStringsToArrayJsonMergerTest extends AbstractMergeCase
{
public function testIdenticalNamespaces(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Symplify\MonorepoBuilder\Tests\Merge\Package;

final class PackageComposerJsonMergerTest extends AbstractMergeTestCase
final class PackageComposerJsonMergerTest extends AbstractMergeCase
{
public function test(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace Symplify\MonorepoBuilder\Tests\Merge\PathResolver;

use Symplify\MonorepoBuilder\Merge\PathResolver\AutoloadPathNormalizer;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;
use Symplify\SmartFileSystem\SmartFileInfo;

final class AutoloadPathNormalizerTest extends AbstractComposerJsonDecoratorTest
final class AutoloadPathNormalizer extends AbstractComposerJsonDecorator
{
private AutoloadPathNormalizer $autoloadPathNormalizer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace Symplify\MonorepoBuilder\Tests\Merge\PathResolver;

use Symplify\MonorepoBuilder\Merge\PathResolver\ComposerPatchesPathNormalizer;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;

final class ComposerPatchesPathNormalizerTest extends AbstractComposerJsonDecoratorTest
final class ComposerPatchesPathNormalizer extends AbstractComposerJsonDecorator
{
protected function setUp(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
use Iterator;
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
use Symplify\MonorepoBuilder\Propagate\VersionPropagator;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecoratorTest;
use Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AbstractComposerJsonDecorator;
use Symplify\SmartFileSystem\SmartFileInfo;

final class VersionPropagaterTest extends AbstractComposerJsonDecoratorTest
final class VersionPropagater extends AbstractComposerJsonDecorator
{
private VersionPropagator $versionPropagator;

Expand Down
8 changes: 8 additions & 0 deletions packages/ComposerJsonManipulator/ComposerJsonFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ public function createFromArray(array $jsonArray): ComposerJson
$composerJson->setProvide($jsonArray[ComposerJsonSection::PROVIDE]);
}

if (isset($jsonArray[ComposerJsonSection::FUNDING])) {
$composerJson->setFunding($jsonArray[ComposerJsonSection::FUNDING]);
}

if (isset($jsonArray[ComposerJsonSection::SUPPORT])) {
$composerJson->setSupport($jsonArray[ComposerJsonSection::SUPPORT]);
}

$orderedKeys = array_keys($jsonArray);
$composerJson->setOrderedKeys($orderedKeys);

Expand Down
44 changes: 44 additions & 0 deletions packages/ComposerJsonManipulator/ValueObject/ComposerJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ final class ComposerJson
*/
private array $extra = [];

/**
* @var mixed[]
*/
private array $funding = [];

/**
* @var mixed[]
*/
private array $support = [];

/**
* @var array<string, string>
*/
Expand Down Expand Up @@ -336,6 +346,38 @@ public function setExtra(array $extra): void
$this->extra = $extra;
}

/**
* @return mixed[]
*/
public function getFunding(): array
{
return $this->funding;
}

/**
* @param mixed[] $funding
*/
public function setFunding(array $funding): void
{
$this->funding = $funding;
}

/**
* @return mixed[]
*/
public function getSupport(): array
{
return $this->support;
}

/**
* @param mixed[] $support
*/
public function setSupport(array $support): void
{
$this->support = $support;
}

public function getName(): ?string
{
return $this->name;
Expand Down Expand Up @@ -416,6 +458,8 @@ public function getJsonArray(): array
ComposerJsonSection::CONFLICT => $this->conflicts,
ComposerJsonSection::PROVIDE => $this->provide,
ComposerJsonSection::VERSION => $this->version,
ComposerJsonSection::FUNDING => $this->funding,
ComposerJsonSection::SUPPORT => $this->support,
]);

if ($this->minimumStability !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,14 @@ final class ComposerJsonSection
* @var string
*/
public const VERSION = 'version';

/**
* @var string
*/
public const FUNDING = 'funding';

/**
* @var string
*/
public const SUPPORT = 'support';
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use Symplify\MonorepoBuilder\Merge\Contract\ComposerJsonDecoratorInterface;
use Symplify\SmartFileSystem\SmartFileInfo;

/**
* @see \Symplify\MonorepoBuilder\Tests\Merge\Application\MergedAndDecoratedComposerJsonFactoryTest
*/
final class MergedAndDecoratedComposerJsonFactory
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use Symplify\MonorepoBuilder\Merge\Configuration\ModifyingComposerJsonProvider;
use Symplify\MonorepoBuilder\Merge\Contract\ComposerJsonDecoratorInterface;

/**
* @see \Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\AppenderComposerJsonDecorator\AppenderComposerJsonDecoratorTest
*/
final class AppenderComposerJsonDecorator implements ComposerJsonDecoratorInterface
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
use Symplify\MonorepoBuilder\Merge\Contract\ComposerJsonDecoratorInterface;
use Symplify\MonorepoBuilder\ValueObject\Option;

/**
* @see \Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\RemoverComposerJsonDecoratorTest
* @see \Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\RemoverComposerJsonDecorator\RemoverComposerJsonDecoratorTest
*/
final class RemoverComposerJsonDecorator implements ComposerJsonDecoratorInterface
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use Symplify\MonorepoBuilder\ComposerJsonManipulator\ValueObject\ComposerJson;
use Symplify\MonorepoBuilder\Merge\Contract\ComposerJsonDecoratorInterface;

/**
* @see \Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\RepositoryPathComposerJsonDecorator\RepositoryPathComposerJsonDecoratorTest
*/
final class RepositoryPathComposerJsonDecorator implements ComposerJsonDecoratorInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
/**
* Remove inter-dependencies in split packages from root, e.g. symfony/console needs symfony/filesystem in package, but
* it makes no sense to have symfony/filesystem in root of symfony/symfony.
*
* @see \Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonDecorator\RootRemoveComposerJsonDecorator\RootRemoveComposerJsonDecoratorTest
*/
final class RootRemoveComposerJsonDecorator implements ComposerJsonDecoratorInterface
{
Expand Down
3 changes: 0 additions & 3 deletions packages/Merge/ComposerJsonMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
use Symplify\MonorepoBuilder\Merge\Contract\ComposerKeyMergerInterface;
use Symplify\SmartFileSystem\SmartFileInfo;

/**
* @see \Symplify\MonorepoBuilder\Tests\Merge\ComposerJsonMerger\ComposerJsonMergerTest
*/
final class ComposerJsonMerger
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use Symplify\MonorepoBuilder\ComposerJsonManipulator\ValueObject\ComposerJson;
use Symplify\MonorepoBuilder\Merge\Contract\ComposerKeyMergerInterface;

/**
* @see \Symplify\MonorepoBuilder\Tests\Merge\ComposerKeyMerger\MinimalStabilityKeyMergerTest
*/
final class MinimalStabilityKeyMerger implements ComposerKeyMergerInterface
{
public function merge(ComposerJson $mainComposerJson, ComposerJson $newComposerJson): void
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuite name="all">
<directory>tests</directory>
<directory>packages/*/tests</directory>
<directory>packages-tests</directory>
</testsuite>
</phpunit>

0 comments on commit 12fc9fe

Please sign in to comment.