diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6a1aa33 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,35 @@ +name: "Tests" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: [pull_request] +jobs: + build: + name: Build & Unit + runs-on: ubuntu-latest + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image + uses: docker/build-push-action@v6 + with: + context: . + push: false + load: true + tags: storage-dev + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Start storage + run: | + docker compose up -d + + - name: Unit Tests + run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cfb0a89..1b7547e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,9 @@ version: '3.1' services: tests: container_name: tests + working_dir: /usr/src/code build: context: . volumes: - - ./:/usr/src/code \ No newline at end of file + - ./:/usr/src/code + - /usr/src/code/vendor \ No newline at end of file diff --git a/src/Compression/Compression.php b/src/Compression/Compression.php index 36b2db6..dac35c6 100644 --- a/src/Compression/Compression.php +++ b/src/Compression/Compression.php @@ -113,7 +113,7 @@ public static function fromAcceptEncoding(string $acceptEncoding, array $support if (empty($supported)) { $supported = [ self::BROTLI => Algorithms\Brotli::isSupported(), - self::GZIP => Algorithms\Gzip::isSupported(), + self::GZIP => Algorithms\GZIP::isSupported(), self::DEFLATE => Algorithms\Deflate::isSupported(), self::IDENTITY => true, ]; diff --git a/tests/Compression/Algorithms/BrotliTest.php b/tests/Compression/Algorithms/BrotliTest.php index 3e47f97..c2801a5 100644 --- a/tests/Compression/Algorithms/BrotliTest.php +++ b/tests/Compression/Algorithms/BrotliTest.php @@ -49,7 +49,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithLargeText() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/lorem.txt'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/lorem.txt'); $demoSize = mb_strlen($demo, '8bit'); $this->object->setLevel(8); @@ -70,7 +70,7 @@ public function testCompressDecompressWithLargeText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = mb_strlen($demo, '8bit'); $this->object->setLevel(8); @@ -89,7 +89,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = mb_strlen($demo, '8bit'); $this->object->setLevel(8); diff --git a/tests/Compression/Algorithms/GZIPTest.php b/tests/Compression/Algorithms/GZIPTest.php index f00fcd4..fff7e8b 100644 --- a/tests/Compression/Algorithms/GZIPTest.php +++ b/tests/Compression/Algorithms/GZIPTest.php @@ -42,7 +42,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithLargeText() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/lorem.txt'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/lorem.txt'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -61,7 +61,7 @@ public function testCompressDecompressWithLargeText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -80,7 +80,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); diff --git a/tests/Compression/Algorithms/LZ4Test.php b/tests/Compression/Algorithms/LZ4Test.php index d3c38ef..89f346e 100644 --- a/tests/Compression/Algorithms/LZ4Test.php +++ b/tests/Compression/Algorithms/LZ4Test.php @@ -39,7 +39,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -58,7 +58,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); diff --git a/tests/Compression/Algorithms/SnappyTest.php b/tests/Compression/Algorithms/SnappyTest.php index a1b9ed5..5859577 100644 --- a/tests/Compression/Algorithms/SnappyTest.php +++ b/tests/Compression/Algorithms/SnappyTest.php @@ -43,7 +43,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -62,7 +62,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); diff --git a/tests/Compression/Algorithms/XZTest.php b/tests/Compression/Algorithms/XZTest.php index 226075b..c81871b 100644 --- a/tests/Compression/Algorithms/XZTest.php +++ b/tests/Compression/Algorithms/XZTest.php @@ -39,7 +39,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -58,7 +58,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); diff --git a/tests/Compression/Algorithms/ZstdTest.php b/tests/Compression/Algorithms/ZstdTest.php index 1b2d51a..7ec65ff 100644 --- a/tests/Compression/Algorithms/ZstdTest.php +++ b/tests/Compression/Algorithms/ZstdTest.php @@ -39,7 +39,7 @@ public function testCompressDecompressWithText() public function testCompressDecompressWithLargeText() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/lorem.txt'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/lorem.txt'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -58,7 +58,7 @@ public function testCompressDecompressWithLargeText() public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-a/kitten-1.jpg'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -77,7 +77,7 @@ public function testCompressDecompressWithJPGImage() public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../resources/disk-b/kitten-1.png'); $demoSize = \mb_strlen($demo, '8bit'); $data = $this->object->compress($demo);