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
46 changes: 45 additions & 1 deletion infection.json5.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,51 @@
}
},
"mutators": {
"@default": true
"@default": true,
"DecrementInteger": {
"ignore": [
// implode() discards keys, so array_fill()'s start index cannot be observed.
"PhpDb\\Sql\\Argument\\Identifiers::getSpecification",
"PhpDb\\Sql\\Argument\\Values::getSpecification",
"PhpDb\\Sql\\Ddl\\Constraint\\ForeignKey::getExpressionData"
]
},
"IncrementInteger": {
"ignore": [
// implode() discards keys, so array_fill()'s start index cannot be observed.
"PhpDb\\Sql\\Argument\\Identifiers::getSpecification",
"PhpDb\\Sql\\Argument\\Values::getSpecification",
"PhpDb\\Sql\\Ddl\\Constraint\\ForeignKey::getExpressionData"
]
},
"MethodCallRemoval": {
"ignore": [
// Delegates to getColumnNames(), which loads the same data itself.
"PhpDb\\Metadata\\Source\\AbstractSource::getColumns"
]
},
"ReturnRemoval": {
"ignore": [
// The guard short-circuits prepareDataHierarchy(), which is itself
// idempotent, so falling through to it has no observable effect.
"PhpDb\\Metadata\\Source\\AbstractSource::loadColumnData",
"PhpDb\\Metadata\\Source\\AbstractSource::loadConstraintData",
"PhpDb\\Metadata\\Source\\AbstractSource::loadConstraintDataKeys",
"PhpDb\\Metadata\\Source\\AbstractSource::loadConstraintReferences",
"PhpDb\\Metadata\\Source\\AbstractSource::loadTableNameData",
"PhpDb\\Metadata\\Source\\AbstractSource::loadTriggerData",
// A RowGatewayInterface is neither null nor a string, so the next guard
// returns for exactly the inputs this one does.
"PhpDb\\TableGateway\\Feature\\RowGatewayFeature::postInitialize"
]
},
"TrueValue": {
"ignore": [
// The method body is empty; the flag is accepted for interface
// compatibility and never read.
"PhpDb\\TableGateway\\Feature\\EventFeature\\TableGatewayEvent::stopPropagation"
]
}
},
"staticAnalysisTool": "mago"
}
15 changes: 15 additions & 0 deletions test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,21 @@ public function testSetStateWithCustomAdapterName(): void
$delegator = AdapterInterfaceDelegator::__set_state(['adapterName' => 'custom']);

self::assertInstanceOf(AdapterInterfaceDelegator::class, $delegator);

$container = $this->createMock(ContainerInterface::class);
$container->expects(self::once())
->method('has')
->with('custom')
->willReturn(false);

self::expectException(ServiceNotFoundException::class);
self::expectExceptionMessage(sprintf(ContainerException::MISSING_SERVICE, 'custom'));

$delegator(
$container,
ConcreteAdapterAwareObject::class,
static fn(): ConcreteAdapterAwareObject => new ConcreteAdapterAwareObject(),
);
}

public function testSetStateWithDefaultAdapterName(): void
Expand Down
7 changes: 7 additions & 0 deletions test/unit/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PhpDb\Sql;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

#[CoversClass(ConfigProvider::class)]
Expand Down Expand Up @@ -40,6 +41,12 @@ class ConfigProviderTest extends TestCase
],
];

#[Test]
public function getDependenciesIsCallableAsPartOfThePublicApi(): void
{
static::assertEquals($this->config['dependencies'], (new ConfigProvider())->getDependencies());
}

public function testInvocationProvidesDependencyConfiguration(): void
{
self::assertEquals($this->config, (new ConfigProvider())());
Expand Down
6 changes: 6 additions & 0 deletions test/unit/Exception/ContainerExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public function forNonAdapterAwareDelegateRendersItsTemplate(): void
);
}

#[Test]
public function forServiceCreatesExceptionWithoutACode(): void
{
self::assertSame(0, ContainerException::forService('Svc', 'Factory', 'reason')->getCode());
}

#[Test]
public function forServiceIsAPsrContainerException(): void
{
Expand Down
18 changes: 18 additions & 0 deletions test/unit/Metadata/Object/ColumnObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,24 @@ public function setErratasIteratesCorrectly(): void
static::assertSame('value2', $column->getErrata('key2'));
}

/**
* Erratas accumulate: a second call adds to what is already there rather than
* replacing it.
*/
#[Test]
public function setErratasMergesIntoTheExistingErrata(): void
{
$column = new ColumnObject('column', 'table', 'schema');

$column->setErratas(['auto_increment' => true]);
$column->setErratas(['comment' => 'Primary key']);

static::assertSame(
['auto_increment' => true, 'comment' => 'Primary key'],
$column->getErratas(),
);
}

#[Test]
public function setErratasWithArrayAndGetErratas(): void
{
Expand Down
Loading
Loading