Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ueberdosis/tiptap-php": "^1.3"
},
"require-dev": {
"21torr/janus": "^1.5.1",
"21torr/janus": "^2.0.3",
"bamarni/composer-bin-plugin": "^1.8.2",
"phpunit/phpunit": "^12.2.5",
"roave/security-advisories": "dev-latest"
Expand All @@ -56,6 +56,7 @@
},
"config": {
"allow-plugins": {
"21torr/janus": true,
"bamarni/composer-bin-plugin": true
},
"sort-packages": true
Expand All @@ -72,15 +73,15 @@
"scripts": {
"fix-lint": [
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --ansi",
"PHP_CS_FIXER_IGNORE_ENV=1 vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi"
"vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --no-interaction --ansi"
],
"lint": [
"@composer bin c-norm normalize \"$(pwd)/composer.json\" --indent-style tab --indent-size 1 --dry-run --ansi",
"PHP_CS_FIXER_IGNORE_ENV=1 vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --no-interaction --ansi"
"vendor-bin/cs-fixer/vendor/bin/php-cs-fixer check --diff --config vendor-bin/cs-fixer/vendor/21torr/php-cs-fixer/.php-cs-fixer.dist.php --allow-unsupported-php-version=yes --no-interaction --ansi"
],
"test": [
"phpunit",
"vendor-bin/phpstan/vendor/bin/phpstan analyze -c phpstan.neon . --ansi -v"
]
}
}
}
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ includes:

parameters:

# If you use simple-phpunit, you need to uncomment the following line.
# Always make sure to first run simple-phpunit and then PHPStan.
# bootstrapFiles:
# - vendor/bin/.phpunit/phpunit/vendor/autoload.php

# These are temporarily copied here, as normally they should be in the lib.neon of janus.
# However, due to a bug in PHPStan, this currently doesn't work (https://github.com/phpstan/phpstan/issues/12844)
excludePaths:
Expand Down
4 changes: 2 additions & 2 deletions tests/Context/ComponentContextTestHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ private function createDummyContext (
) : ComponentContext
{
return new ComponentContext(
$componentManager ?? $this->createMock(ComponentManager::class),
$componentManager ?? $this->createStub(ComponentManager::class),
$dataTransformer ?? new DataTransformer(),
$logger ?? new NullLogger(),
$validator ?? $this->createMock(DataValidator::class),
$validator ?? $this->createStub(DataValidator::class),
$imageDimensionsExtractor ?? new ImageDimensionsExtractor(),
);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Field/Definition/BloksFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class BloksFieldTest extends TestCase
public function testInvalidComponents () : void
{
$field = new BloksField("test");
$manager = $this->createMock(ComponentManager::class);
$manager = self::createStub(ComponentManager::class);

$context = $this->createDummyContext($manager);

Expand Down Expand Up @@ -81,7 +81,7 @@ public function testIgnoredComponentsCount (
minimumNumberOfBloks: $minCount,
maximumNumberOfBloks: $maxCount,
);
$manager = $this->createMock(ComponentManager::class);
$manager = self::createStub(ComponentManager::class);

$manager->method("getComponent")
->willReturnCallback(function (string $key)
Expand All @@ -91,7 +91,7 @@ public function testIgnoredComponentsCount (
throw new UnknownComponentKeyException("test", "key");
}

return $this->createMock(AbstractComponent::class);
return $this->createStub(AbstractComponent::class);
});

$this->expectException(InvalidDataException::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Field/Definition/ChoiceFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function testInvalid (ChoiceField $field, mixed $data) : void
private function createComponentContext () : ComponentContext
{
return new ComponentContext(
$this->createMock(ComponentManager::class),
self::createStub(ComponentManager::class),
new DataTransformer(),
new NullLogger(),
new DataValidator(),
Expand Down
64 changes: 64 additions & 0 deletions tests/Fixtures/ComponentA.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php declare(strict_types=1);

namespace Tests\Torr\Storyblok\Fixtures;

use Torr\Storyblok\Component\AbstractComponent;
use Torr\Storyblok\Component\Config\ComponentType;

/**
* @final
*/
class ComponentA extends AbstractComponent
{
/**
*/
public function __construct (
/** @var list<string> */
private readonly array $tags = [],
) {}

/**
*
*/
#[\Override]
public static function getKey () : string
{
return "a";
}

/**
*
*/
#[\Override]
protected function configureFields () : array
{
return [];
}

/**
*
*/
#[\Override]
protected function getComponentType () : ComponentType
{
return ComponentType::Standalone;
}

/**
*
*/
#[\Override]
public function getDisplayName () : string
{
return "A";
}

/**
*
*/
#[\Override]
public function getTags () : array
{
return $this->tags;
}
}
64 changes: 64 additions & 0 deletions tests/Fixtures/ComponentB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php declare(strict_types=1);

namespace Tests\Torr\Storyblok\Fixtures;

use Torr\Storyblok\Component\AbstractComponent;
use Torr\Storyblok\Component\Config\ComponentType;

/**
* @final
*/
class ComponentB extends AbstractComponent
{
/**
*/
public function __construct (
/** @var list<string> */
private readonly array $tags = [],
) {}

/**
*
*/
#[\Override]
public static function getKey () : string
{
return "b";
}

/**
*
*/
#[\Override]
protected function configureFields () : array
{
return [];
}

/**
*
*/
#[\Override]
protected function getComponentType () : ComponentType
{
return ComponentType::Standalone;
}

/**
*
*/
#[\Override]
public function getDisplayName () : string
{
return "B";
}

/**
*
*/
#[\Override]
public function getTags () : array
{
return $this->tags;
}
}
64 changes: 64 additions & 0 deletions tests/Fixtures/ComponentC.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php declare(strict_types=1);

namespace Tests\Torr\Storyblok\Fixtures;

use Torr\Storyblok\Component\AbstractComponent;
use Torr\Storyblok\Component\Config\ComponentType;

/**
* @final
*/
class ComponentC extends AbstractComponent
{
/**
*/
public function __construct (
/** @var list<string> */
private readonly array $tags = [],
) {}

/**
*
*/
#[\Override]
public static function getKey () : string
{
return "c";
}

/**
*
*/
#[\Override]
protected function configureFields () : array
{
return [];
}

/**
*
*/
#[\Override]
protected function getComponentType () : ComponentType
{
return ComponentType::Standalone;
}

/**
*
*/
#[\Override]
public function getDisplayName () : string
{
return "B";
}

/**
*
*/
#[\Override]
public function getTags () : array
{
return $this->tags;
}
}
64 changes: 64 additions & 0 deletions tests/Fixtures/ComponentD.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php declare(strict_types=1);

namespace Tests\Torr\Storyblok\Fixtures;

use Torr\Storyblok\Component\AbstractComponent;
use Torr\Storyblok\Component\Config\ComponentType;

/**
* @final
*/
class ComponentD extends AbstractComponent
{
/**
*/
public function __construct (
/** @var list<string> */
private readonly array $tags = [],
) {}

/**
*
*/
#[\Override]
public static function getKey () : string
{
return "d";
}

/**
*
*/
#[\Override]
protected function configureFields () : array
{
return [];
}

/**
*
*/
#[\Override]
protected function getComponentType () : ComponentType
{
return ComponentType::Standalone;
}

/**
*
*/
#[\Override]
public function getDisplayName () : string
{
return "B";
}

/**
*
*/
#[\Override]
public function getTags () : array
{
return $this->tags;
}
}
Loading