Skip to content

Commit

Permalink
Merge pull request #3357 from ColoredCow/feature/hr-unit-test
Browse files Browse the repository at this point in the history
fix(*): HR unit tests
  • Loading branch information
pankaj-ag authored Sep 15, 2023
2 parents 6bfd410 + d970b7e commit f8b522a
Show file tree
Hide file tree
Showing 22 changed files with 8,725 additions and 354 deletions.
2 changes: 1 addition & 1 deletion .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ APP_TIMEZONE=UTC

DB_CONNECTION=testing
DB_TEST_DATABASE=portal_test
DB_TEST_USERNAME='root'
DB_TEST_USERNAME='mysql_test_user'
DB_TEST_PASSWORD='root'

CACHE_DRIVER=array
Expand Down
50 changes: 0 additions & 50 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,6 @@ on:
branches: [master]

jobs:
# phpcs:
# name: PHP CS
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Setup PHP v8.2
# uses: shivammathur/setup-php@v2
# with:
# php-version: "8.2"
# - name: Install composer dependencies
# run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
# - name: PHP Coding Standards
# run: PHP_CS_FIXER_IGNORE_ENV=1 php ./vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php --dry-run --verbose --diff

# eslint:
# name: ES Lint
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Setup PHP v8.2
# uses: shivammathur/setup-php@v2
# with:
# php-version: "8.2"
# - name: Install composer dependencies
# run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
# - name: Install NPM Dependencies
# run: npm install
# - name: ESLINT
# run: ./node_modules/.bin/eslint resources/js/ Modules/*/Resources/assets/js/ --ext .js,.vue

# larastan:
# name: Larastan
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Setup PHP v8.2
# uses: shivammathur/setup-php@v2
# with:
# php-version: "8.2"
# - name: Install composer dependencies
# run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
# - name: Setup env file
# run: cp ./.env.example .env
# - name: Configure application encryption key
# run: php artisan key:generate
# - name: clear cache
# run: php artisan view:clear
# - name: Larastan
# run: ./vendor/bin/phpstan analyse

ColoredCowLaravelCI:
name: ColoredCowLaravelCI
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup PHP v8.2
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: "8.2"

- name: Setup cypress-testing
uses: actions/checkout@v2
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/unit-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Unit testing

# Controls when the action will run.
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
portal:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_USER: mysql_test_user
MYSQL_PASSWORD: root
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: portal_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# cypress setup
- name: Setup PHP v7.4
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"

- name: Setup unit-testing
uses: actions/checkout@v2

- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Install Dependencies
run: composer install

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Run migrations
run: |
php artisan migrate --env=testing
- name: Run seeders
run: |
php artisan db:seed --env=testing
php artisan module:seed --env=testing
- name: Compile assets
run: |
export NODE_OPTIONS=--openssl-legacy-provider
npm install
npm run dev
- name: Run Test Suit
run: |
vendor/bin/phpunit --coverage-clover coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ cypress/screenshots
google_service_credentials.json

.phpunit.result.cache
.phpunit.result.cache/

# Unit test / coverage reports
coverage.xml
codecov
codecov/
1 change: 0 additions & 1 deletion .husky/_/.gitignore

This file was deleted.

29 changes: 0 additions & 29 deletions .husky/_/husky.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/_/pre-commit

This file was deleted.

1 change: 0 additions & 1 deletion .phpunit.result.cache

This file was deleted.

2 changes: 1 addition & 1 deletion Modules/HR/Database/Seeders/HRDatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HRDatabaseSeeder extends Seeder
*/
public function run()
{
if (! app()->environment(['local', 'staging', 'UAT'])) {
if (! app()->environment(['local', 'staging', 'UAT', 'testing'])) {
return 0;
}
$this->call(HRPermissionsTableSeeder::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Tests\Feature\HR;
namespace Modules\HR\Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class ExampleTest extends TestCase
class ApplicantTest extends TestCase
{
use RefreshDatabase;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

namespace Tests\Unit\HR;
namespace Modules\HR\Tests\Unit;

/*
* @var \Illuminate\Database\Eloquent\Factory $factory
*/

use Modules\HR\Entities\Applicant;
use Tests\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Project/Contract/ProjectServiceContract.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Modules\Project\Contracts;
namespace Modules\Project\Contract;

interface ProjectServiceContract
{
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## ColoredCow Portal

![GitHub issues](https://img.shields.io/github/issues/coloredcow/portal)
[![codecov](https://codecov.io/gh/ColoredCow/portal/graph/badge.svg?token=LO38hOYgBT)](https://codecov.io/gh/ColoredCow/portal)
[![Coding Standards](https://github.com/coloredcow/portal/actions/workflows/coding-standards.yml/badge.svg?branch=master)](https://github.com/coloredcow/portal/actions/workflows/coding-standards.yml)
[![Staging Deployment](https://github.com/ColoredCow/portal/actions/workflows/staging-deployment.yml/badge.svg)](https://github.com/ColoredCow/portal/actions/workflows/staging-deployment.yml)

Expand Down
86 changes: 0 additions & 86 deletions app/User.php

This file was deleted.

4 changes: 2 additions & 2 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@

'testing' => [
'driver' => 'mysql',
'host' => env('DB_TEST_HOST', '127.0.0.1'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_TEST_DATABASE', 'portal_test'),
'username' => env('DB_TEST_USERNAME', 'root'),
'username' => env('DB_TEST_USERNAME', 'mysql_test_user'),
'password' => env('DB_TEST_PASSWORD', 'root'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
Expand Down
Loading

0 comments on commit f8b522a

Please sign in to comment.