Skip to content
Closed

test #86

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
1 change: 1 addition & 0 deletions .github/workflows/backend_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Run Laravel API Feature Tests
on:
pull_request:
branches:
- deployment
- development
paths:
- 'API/**'
Expand Down
71 changes: 71 additions & 0 deletions API/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Be sure to copy this into your .env file and ask for any necessary keys to test
APP_NAME=API
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=localhost:8000
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=localhost:3000
SANCTUM_STATEFUL_DOMAINS=localhost,localhost:3000,localhost:8000
SESSION_DOMAIN=localhost
FRONTEND_BASE_URL=localhost:3000
SESSION_SECURE_COOKIE=false
DEBUGBAR_ENABLED=false

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stderr
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=db
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=root
DB_PORT=3306

SESSION_DRIVER=cookie
SESSION_LIFETIME=43200
SESSION_ENCRYPT=false
SESSION_PATH=/

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME=${APP_NAME}
2 changes: 1 addition & 1 deletion API/app/Http/Controllers/Api/ShoppingListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function getSharedShoppingLists(Request $request)
$shoppingListIds = $sharedPermissionEntries->pluck('shopping_list_id');

// Step 3: Retrieve shopping lists based on the IDs
$shoppingLists = ShoppingList::whereIn('id', $shoppingListIds)->get();
$shoppingLists = ShoppingList::whereIn('list_id', $shoppingListIds)->get();

return response()->json($shoppingLists, 200);
}
Expand Down
39 changes: 15 additions & 24 deletions API/docker/development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
# Use the official PHP 8.2 CLI image
FROM php:8.2-cli-alpine

# Set working directory
WORKDIR /var/www/html
# Use official PHP image with necessary extensions
FROM php:8.2-fpm

# Install system dependencies
RUN apk add --no-cache \
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libjpeg-dev \
libfreetype6-dev \
libxml2-dev \
oniguruma-dev \
libonig-dev \
unzip \
zip \
git \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd pdo pdo_mysql mbstring xml

# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd pdo pdo_mysql mbstring xml

# Install Composer globally
COPY --from=composer:2.6 /usr/bin/composer /usr/bin/composer

# Copy application source
COPY . /var/www/html

# Install dependencies
RUN composer install
# Set working directory
WORKDIR /var/www

# Set correct permissions
RUN chmod -R 777 storage bootstrap/cache
# Set permissions
RUN chown -R www-data:www-data /var/www && chmod -R 755 /var/www

# Expose port 8000 for Laravel's dev server
# Expose port 8000 for Laravel's dev server and start development server
EXPOSE 8000

# Start Laravel development server
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]
CMD ["php-fpm"]
28 changes: 22 additions & 6 deletions API/docker/development/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
version: '3.8'

services:
app:
build:
context: ../../
dockerfile: ./docker/development/Dockerfile
container_name: laravel_dev
container_name: speedcart_laravel_dev
ports:
- "8000:8000"
- "9000:9000"
depends_on:
- db
env_file:
- ../../.env
volumes:
- ../../:/var/www
# Make sure the following variables are set in .env
# for the db connection to function properly:
# APP_ENV=local
Expand All @@ -26,15 +27,30 @@ services:

db:
image: mysql:8.0
container_name: laravel_db
restart: always
container_name: speedcart_laravel_mysql
restart: unless-stopped
environment:
MYSQL_DATABASE: laravel
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: laravel
MYSQL_PASSWORD: secret
volumes:
- db_data:/var/lib/mysql
ports:
- "127.0.0.1:3306:3306"
- "3306:3306"
networks:
- laravel_network

nginx:
image: nginx:alpine
container_name: speedcart_nginx
ports:
- "8000:80" # 8000 on host → 80 on container
volumes:
- ../../:/var/www
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- app
networks:
- laravel_network

Expand Down
19 changes: 19 additions & 0 deletions API/docker/development/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
server {
listen 80;
server_name localhost;

root /var/www/public;

index index.php index.html;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/public$fastcgi_script_name;
}
}
14 changes: 13 additions & 1 deletion API/docker/production/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,26 @@ RUN apt-get update && apt-get install -y \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-install pdo pdo_mysql mbstring exif pcntl bcmath gd intl zip soap
RUN docker-php-ext-install pdo pdo_mysql mbstring exif pcntl bcmath gd intl zip soap opcache

# Copy custom opcache configuration
COPY ./opcache.ini /usr/local/etc/php/conf.d/opcache.ini

# Enable Apache Rewrite module (required by Laravel)
RUN a2enmod rewrite

# Copy existing application directory contents
COPY . /var/www/html

# Set Apache to serve the Laravel "public" directory
RUN sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/public|' /etc/apache2/sites-available/000-default.conf

# Also allow .htaccess overrides in public directory
RUN echo '<Directory /var/www/html/public>\n\
AllowOverride All\n\
Require all granted\n\
</Directory>' >> /etc/apache2/apache2.conf

# Copy existing application directory permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
Expand Down
9 changes: 9 additions & 0 deletions API/opcache.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; Enable OPcache
zend_extension=opcache
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=2
opcache.validate_timestamps=1
1 change: 0 additions & 1 deletion Frontend/shared/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
API_DOMAIN=api.speedcartapp.com
API_PORT=80
TESTING_MODE=false
3 changes: 1 addition & 2 deletions Frontend/shared/src/constants/BaseUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import config from './config.json';

const API_DOMAIN = config.API_DOMAIN;
const API_PORT = config.API_PORT;

// Protocol depends on if we're using dev or production
const API_PROTOCOL = API_DOMAIN === 'localhost' ? 'http' : 'https';

// This can be reused for all backend interactions
export const BASE_URL: string = `${API_PROTOCOL}://${API_DOMAIN}:${API_PORT}`;
export const BASE_URL: string = `${API_PROTOCOL}://${API_DOMAIN}`;
export const TESTING_MODE: boolean = config.TESTING_MODE === 'true';
88 changes: 0 additions & 88 deletions tests/CrudOpsTest.php

This file was deleted.

Loading