Skip to content

Commit

Permalink
fix: fix phpspec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroTroller committed Oct 23, 2023
1 parent dd628b0 commit b3fa95d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/Gaufrette/Adapter/DoctrineDbalSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function it_calculates_checksum(Connection $connection)
->$method('SELECT "checksum" FROM "someTableName" WHERE "key" = :key', ['key' => 'filename'])
->willReturn(1234);

$this->checksum('filename')->shouldReturn(1234);
$this->checksum('filename')->shouldReturn("1234");
}

function it_gets_mtime(Connection $connection)
Expand Down
2 changes: 1 addition & 1 deletion spec/Gaufrette/Adapter/FlysystemSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function it_writes_file(AdapterInterface $adapter, Config $config)
{
$adapter->write('filename', 'Hello.', $config)->willReturn([]);

$this->write('filename', 'Hello.')->shouldReturn([]);
$this->write('filename', 'Hello.')->shouldReturn(0);
}

function it_checks_if_file_exists(AdapterInterface $adapter)
Expand Down
12 changes: 11 additions & 1 deletion src/Gaufrette/Adapter/Flysystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ public function read(string $key): string|bool
*/
public function write(string $key, mixed $content): int|bool
{
return $this->adapter->write($key, $content, $this->config);
$metadata = $this->adapter->write($key, $content, $this->config);

if (false === $metadata) {
return false;
}

if (is_int($metadata['size'] ?? 0)) {
return $metadata['size'] ?? 0;
}

return 0;
}

/**
Expand Down

0 comments on commit b3fa95d

Please sign in to comment.