Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue we had on our Symfony 6.4 project while using this package #1324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion pkg/fs/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
with:
composer-options: "--prefer-source"

- run: SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/phpunit --exclude-group=functional
- run: SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/phpunit
6 changes: 3 additions & 3 deletions pkg/fs/FsConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public function createContext(): Context
{
return new FsContext(
$this->config['path'],
$this->config['pre_fetch_count'],
$this->config['chmod'],
$this->config['polling_interval']
intval($this->config['pre_fetch_count']),
is_string($this->config['chmod']) ? octdec($this->config['chmod']) : $this->config['chmod'],
intval($this->config['polling_interval'])
);
}

Expand Down
17 changes: 17 additions & 0 deletions pkg/fs/Tests/FsConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ public function testShouldImplementConnectionFactoryInterface()
$this->assertClassImplements(ConnectionFactory::class, FsConnectionFactory::class);
}

public function testThatItDoesNotCrashOnStringNumericValues()
{
$factory = new FsConnectionFactory([
'path' => __DIR__,
'pre_fetch_count' => '123',
'chmod' => '0765',
]);

$context = $factory->createContext();

$this->assertInstanceOf(FsContext::class, $context);

$this->assertAttributeSame(__DIR__, 'storeDir', $context);
$this->assertAttributeSame(123, 'preFetchCount', $context);
$this->assertAttributeSame(0765, 'chmod', $context);
}

public function testShouldCreateContext()
{
$factory = new FsConnectionFactory([
Expand Down
11 changes: 4 additions & 7 deletions pkg/fs/Tests/FsConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ public function testShouldImplementConsumerInterface()
$this->assertClassImplements(Consumer::class, FsConsumer::class);
}

public function testCouldBeConstructedWithContextAndDestinationAndPreFetchCountAsArguments()
{
new FsConsumer($this->createContextMock(), new FsDestination(TempFile::generate()), 1);
}

public function testShouldReturnDestinationSetInConstructorOnGetQueue()
{
$destination = new FsDestination(TempFile::generate());
Expand Down Expand Up @@ -53,15 +48,17 @@ public function testShouldAllowGetPreviouslySetPreFetchCount()
public function testShouldDoNothingOnAcknowledge()
{
$consumer = new FsConsumer($this->createContextMock(), new FsDestination(TempFile::generate()), 123);

$cloneWithInitialState = clone $consumer;
$consumer->acknowledge(new FsMessage());
$this->assertEquals($cloneWithInitialState, $consumer);
}

public function testShouldDoNothingOnReject()
{
$consumer = new FsConsumer($this->createContextMock(), new FsDestination(TempFile::generate()), 123);

$cloneWithInitialState = clone $consumer;
$consumer->reject(new FsMessage());
$this->assertEquals($cloneWithInitialState, $consumer);
}

public function testCouldSetAndGetPollingInterval()
Expand Down
11 changes: 5 additions & 6 deletions pkg/fs/Tests/FsContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ public function testShouldImplementContextInterface()
$this->assertClassImplements(Context::class, FsContext::class);
}

public function testCouldBeConstructedWithExpectedArguments()
{
new FsContext(sys_get_temp_dir(), 1, 0666, 100);
}

public function testShouldAllowCreateEmptyMessage()
{
$context = new FsContext(sys_get_temp_dir(), 1, 0666, 100);
Expand Down Expand Up @@ -130,7 +125,11 @@ public function testShouldCreateConsumer()

$queue = $context->createQueue($tmpFile->getFilename());

$context->createConsumer($queue);
$this->assertSame(
100,
$context->createConsumer($queue)->getPollingInterval()
);

}

public function testShouldPropagatePreFetchCountToCreatedConsumer()
Expand Down
7 changes: 1 addition & 6 deletions pkg/fs/Tests/FsProducerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ class FsProducerTest extends \PHPUnit\Framework\TestCase

public function testShouldImplementProducerInterface()
{
$this->assertClassImplements(Producer::class, FsProducer::class);
}

public function testCouldBeConstructedWithContextAsFirstArgument()
{
new FsProducer($this->createContextMock());
$this->assertInstanceOf(Producer::class, new FsProducer($this->createContextMock()));
}

public function testThrowIfDestinationNotFsOnSend()
Expand Down
1 change: 1 addition & 0 deletions pkg/fs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"phpunit/phpunit": "^9.5",
"enqueue/null": "0.10.x-dev",
"enqueue/test": "0.10.x-dev",
"enqueue/enqueue": "0.10.x-dev",
"queue-interop/queue-spec": "^0.6.2",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0"
Expand Down
34 changes: 11 additions & 23 deletions pkg/fs/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
colors="true"
bootstrap="./vendor/autoload.php"
>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" bootstrap="./vendor/autoload.php">
<coverage>
<include>
<directory suffix=".php">.</directory>
</include>
<exclude>
<directory>./vendor</directory>
<directory>./Resources</directory>
<directory>./Tests</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Enqueue Filesystem Transport">
<directory>./Tests</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>

<filter>
<whitelist>
<directory suffix=".php">.</directory>
<exclude>
<directory>./vendor</directory>
<directory>./Resources</directory>
<directory>./Tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>