diff --git a/pkg/fs/.github/workflows/ci.yml b/pkg/fs/.github/workflows/ci.yml index 65cfbbb2d..e88be7491 100644 --- a/pkg/fs/.github/workflows/ci.yml +++ b/pkg/fs/.github/workflows/ci.yml @@ -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 diff --git a/pkg/fs/FsConnectionFactory.php b/pkg/fs/FsConnectionFactory.php index ad13e9eb6..0489b9779 100644 --- a/pkg/fs/FsConnectionFactory.php +++ b/pkg/fs/FsConnectionFactory.php @@ -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']) ); } diff --git a/pkg/fs/Tests/FsConnectionFactoryTest.php b/pkg/fs/Tests/FsConnectionFactoryTest.php index 2df442342..0c816623a 100644 --- a/pkg/fs/Tests/FsConnectionFactoryTest.php +++ b/pkg/fs/Tests/FsConnectionFactoryTest.php @@ -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([ diff --git a/pkg/fs/Tests/FsConsumerTest.php b/pkg/fs/Tests/FsConsumerTest.php index 086bb55fe..37424615c 100644 --- a/pkg/fs/Tests/FsConsumerTest.php +++ b/pkg/fs/Tests/FsConsumerTest.php @@ -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()); @@ -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() diff --git a/pkg/fs/Tests/FsContextTest.php b/pkg/fs/Tests/FsContextTest.php index 4bc05e9de..ea9731a49 100644 --- a/pkg/fs/Tests/FsContextTest.php +++ b/pkg/fs/Tests/FsContextTest.php @@ -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); @@ -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() diff --git a/pkg/fs/Tests/FsProducerTest.php b/pkg/fs/Tests/FsProducerTest.php index 28700d52f..63cb0d40c 100644 --- a/pkg/fs/Tests/FsProducerTest.php +++ b/pkg/fs/Tests/FsProducerTest.php @@ -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() diff --git a/pkg/fs/composer.json b/pkg/fs/composer.json index b44900541..12b07d308 100644 --- a/pkg/fs/composer.json +++ b/pkg/fs/composer.json @@ -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" diff --git a/pkg/fs/phpunit.xml.dist b/pkg/fs/phpunit.xml.dist index 79088ae1d..2beba466e 100644 --- a/pkg/fs/phpunit.xml.dist +++ b/pkg/fs/phpunit.xml.dist @@ -1,30 +1,18 @@ - - - + + + + . + + + ./vendor + ./Resources + ./Tests + + ./Tests - - - - - - - - . - - ./vendor - ./Resources - ./Tests - - -