Skip to content

Commit 4d82f3f

Browse files
Copilotstnguyen90
andcommitted
Move Composer setup to test script and composer.json to tests folder
Co-authored-by: stnguyen90 <1477010+stnguyen90@users.noreply.github.com>
1 parent 360beb5 commit 4d82f3f

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

Dockerfile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,6 @@ COPY --from=mongodb /usr/local/lib/php/extensions/no-debug-non-zts-20240924/mong
234234
# Enable Extensions
235235
RUN docker-php-ext-enable swoole redis imagick yaml maxminddb scrypt zstd brotli lz4 snappy opentelemetry protobuf gd mongodb
236236

237-
# Install Composer
238-
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
239-
240-
# Copy composer.json and install dependencies
241-
COPY composer.json /usr/src/code/composer.json
242-
RUN composer install --no-dev --working-dir=/usr/src/code
243-
244237
# Copy test files
245238
COPY tests /tests
246239

tests.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ commandTests:
8282
expectedOutput:
8383
- "Zip 3.0 \\(July 5th 2008\\)"
8484
- name: 'utopia-php/image PNG to WebP conversion'
85-
command: "php"
86-
args: ["/tests/image-conversion-test.php"]
85+
command: "sh"
86+
args: ["/tests/run-image-conversion-test.sh"]
8787
expectedOutput:
88+
- "Installing Composer..."
89+
- "Installing dependencies..."
8890
- "Test 1: Converting PNG to WebP..."
8991
- "✓ PNG to WebP conversion successful"
9092
- "Test 2: Converting WebP to PNG..."
File renamed without changes.

tests/image-conversion-test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
require_once '/usr/src/code/vendor/autoload.php';
3+
require_once '/tests/vendor/autoload.php';
44

55
use Utopia\Image\Image;
66

tests/run-image-conversion-test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
# Install Composer if not already installed
4+
if ! command -v composer >/dev/null 2>&1; then
5+
echo "Installing Composer..."
6+
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
7+
if [ $? -ne 0 ]; then
8+
echo "✗ Failed to install Composer"
9+
exit 1
10+
fi
11+
fi
12+
13+
# Install dependencies
14+
echo "Installing dependencies..."
15+
cd /tests
16+
composer install --no-dev --quiet
17+
if [ $? -ne 0 ]; then
18+
echo "✗ Failed to install dependencies"
19+
exit 1
20+
fi
21+
22+
# Run the test
23+
php /tests/image-conversion-test.php

0 commit comments

Comments
 (0)