Skip to content

Commit

Permalink
Merge pull request #70 from medcenter24/release_4.0.0
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
zagovorichev authored Jul 17, 2021
2 parents ac4caca + 3a6cd6e commit d6b60f5
Show file tree
Hide file tree
Showing 179 changed files with 69,709 additions and 1,287 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ package-lock.json
_ide_helper.php
_ide_helper_models.php
/.phpunit.result.cache
/DevEnvConfig
15 changes: 15 additions & 0 deletions Docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
run:
docker-compose up -d
docker exec -it mc-core-build composer install
docker exec -it mc-core-build yarn && yarn run dev
docker exec -it mc-core-build /usr/local/bin/php artisan serve --port 4043 --host 0.0.0.0 --env APP_CONFIG_PATH=/var/www/html/DevEnvConfig
stop:
docker-compose down

setup:
docker exec -it mc-core-build /usr/local/bin/php artisan setup:seed
docker exec -it mc-core-build chown 1000:1000 -R /var/www/html/DevEnvConfig
docker exec -it mc-core-build chmod +rw -R /var/www/html/DevEnvConfig

test:
docker exec -it mc-core-build /usr/local/bin/php artisan test
42 changes: 42 additions & 0 deletions Docker/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM php:8.0-fpm

# Dependencies needed for packages downstream
RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libpq-dev git zip unzip zlib1g-dev g++ wget fontconfig \
locales gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 \
libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 \
libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 \
libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils \
libicu-dev libonig-dev libzip-dev && \
rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-configure gd --with-freetype --with-jpeg

RUN yes | pecl install xdebug

RUN docker-php-ext-install pdo && \
docker-php-ext-install gd && \
docker-php-ext-install exif && \
docker-php-ext-install zip && \
docker-php-ext-enable xdebug

RUN { \
echo 'xdebug.mode=debug'; \
echo 'xdebug.discover_client_host = 1'; \
} >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN { \
echo 'memory_limit=512M'; \
} >> /usr/local/etc/php/conf.d/docker-php-ext-memory-limit.ini

# Composer
RUN curl -ksS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer

# Node + Yarn
RUN curl -sL https://deb.nodesource.com/setup_14.x -o /tmp/nodesource_setup.sh \
&& bash /tmp/nodesource_setup.sh \
&& rm /tmp/nodesource_setup.sh \
&& apt-get install --quiet --yes --no-install-recommends nodejs \
&& npm install yarn --global

RUN rm -rf /var/www/html \
&& chmod 0777 /tmp/
26 changes: 26 additions & 0 deletions Docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.9'

services:
mc-core-build:
container_name: mc-core-build
build:
context: ./build
environment:
- APP_CONFIG_PATH=/var/www/html/DevEnvConfig/config/generis.conf.php
ports:
- 4043:4043
networks:
- traefik-public
volumes:
- ..:/var/www/html:cached
working_dir: /var/www/html
labels:
- "traefik.enable=true"
- "traefik.http.routers.mc-core.rule=Host(`core.mc.docker.localhost`)"
- "traefik.http.routers.mc-core.entrypoints=http"
- "traefik.http.routers.mc-core-secure.entrypoints=https"
- "traefik.http.routers.mc-core-secure.rule=Host(`core.mc.docker.localhost`)"
- "traefik.http.routers.mc-core-secure.tls=true"
networks:
traefik-public:
external: true
17 changes: 9 additions & 8 deletions Tests/Feature/Admin/AccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@
namespace medcenter24\mcCore\Tests\Feature\Admin;

use medcenter24\mcCore\App\Entity\User;
use medcenter24\mcCore\App\Support\Facades\Roles;
use medcenter24\mcCore\Tests\TestCase;

class AccessTest extends TestCase
{
// redirect to the admin page
public function testMain(): void
{
\Roles::shouldReceive('hasRole')->times(0);
Roles::shouldReceive('hasRole')->times(0);

$response = $this
->actingAs(factory(User::class)->make())
->actingAs(User::factory()->make())
->get('/');

$response
Expand All @@ -40,44 +41,44 @@ public function testMain(): void

public function testAdmin(): void
{
\Roles::shouldReceive('hasRole')
Roles::shouldReceive('hasRole')
->times(9)
->andReturnUsing(static function ($user, $role) {
return true;
});

$response = $this
->actingAs(factory(User::class)->make())
->actingAs(User::factory()->make())
->get('/admin');

$response->assertStatus(200);
}

public function testDoctor(): void
{
\Roles::shouldReceive('hasRole')
Roles::shouldReceive('hasRole')
->times(5)
->andReturnUsing(function ($user, $role) {
return false;
});

$response = $this
->actingAs(factory(User::class)->make())
->actingAs(User::factory()->make())
->get('/admin');

$response->assertStatus(403);
}

public function testDirector(): void
{
\Roles::shouldReceive('hasRole')
Roles::shouldReceive('hasRole')
->times(5)
->andReturnUsing(function ($user, $role) {
return false;
});

$response = $this
->actingAs(factory(User::class)->make())
->actingAs(User::factory()->make())
->get('/admin');

$response->assertStatus(403);
Expand Down
8 changes: 4 additions & 4 deletions Tests/Feature/Admin/AuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

namespace medcenter24\mcCore\Tests\Feature\Admin;


use medcenter24\mcCore\App\Entity\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Testing\TestResponse;
use medcenter24\mcCore\App\Support\Facades\Roles;
use medcenter24\mcCore\Tests\TestCase;

class AuthorizationTest extends TestCase
Expand Down Expand Up @@ -63,7 +63,7 @@ public function testAuthorization(): void
{
$mail = 'mail@example.com';
$passwd = 'secure';
$this->user = factory(User::class)->create([
$this->user = User::factory()->create([
'email' => $mail,
'password' => bcrypt($passwd),
]);
Expand All @@ -87,12 +87,12 @@ public function testAdminsAuthorization(): void
$mail = 'mail@example.com';
$passwd = 'secure';
/** @var User user */
$this->user = factory(User::class)->create([
$this->user = User::factory()->create([
'email' => $mail,
'password' => bcrypt($passwd),
]);

\Roles::shouldReceive('hasRole')
Roles::shouldReceive('hasRole')
->times(9)
->andReturnUsing(function ($user, $role) {
return true;
Expand Down
5 changes: 3 additions & 2 deletions Tests/Feature/Api/AuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use medcenter24\mcCore\App\Entity\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use medcenter24\mcCore\App\Support\Facades\Roles;
use medcenter24\mcCore\Tests\TestCase;

class AuthorizationTest extends TestCase
Expand All @@ -48,13 +49,13 @@ public function testWrongCredentialsAuthorization(): void

public function testAuthorization(): void
{
\Roles::shouldReceive('hasRole')
Roles::shouldReceive('hasRole')
->andReturnUsing(function () {
return true;
});
$mail = 'mail@example.com';
$passwd = 'secure';
$this->user = factory(User::class)->create([
$this->user = User::factory()->create([
'email' => $mail,
'password' => bcrypt($passwd),
]);
Expand Down
6 changes: 3 additions & 3 deletions Tests/Feature/Api/Director/AssistantsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ public function deleteDataProvider(): array

public function testFilteredSearch(): void
{
factory(Assistant::class)->create(['title' => 'Text to be searched']);
factory(Assistant::class)->create(['title' => 'Php Unit test']);
factory(Assistant::class)->create(['title' => 'another text']);
Assistant::factory()->create(['title' => 'Text to be searched']);
Assistant::factory()->create(['title' => 'Php Unit test']);
Assistant::factory()->create(['title' => 'another text']);

$response = $this->sendPost(self::URI . '/search', [
'filter' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,30 +197,30 @@ public function testCreateWithAccidentDataOnlyAccidentRequestRules(): void
*/
public function testCreateWithAccidentDataOnly4(): void
{
$patient = factory(Patient::class)->create();
$city = factory(City::class)->create();
$assistantPayment = factory(Payment::class)->create();
$caseablePayment = factory(Payment::class)->create();
$income = factory(Payment::class)->create();
$patient = Patient::factory()->create();
$city = City::factory()->create();
$assistantPayment = Payment::factory()->create();
$caseablePayment = Payment::factory()->create();
$income = Payment::factory()->create();
$data = [
'accident' => [
'accidentStatusId' => AccidentStatus::firstOrCreate([
'title' => AccidentStatusService::STATUS_NEW,
'type' => AccidentStatusService::TYPE_ACCIDENT,
])->id,
'accidentTypeId' => factory(AccidentType::class)->create()->id,
'accidentTypeId' => AccidentType::factory()->create()->id,
'address' => 'any',
'assistantId' => factory(Assistant::class)->create()->id,
'assistantId' => Assistant::factory()->create()->id,
'assistantRefNum' => 'ref---',
'caseableId' => factory(DoctorAccident::class)->create()->id,
'caseableId' => DoctorAccident::factory()->create()->id,
'caseableType' => 'doctor',
'cityId' => $city->id,
'closedAt' => null,
'contacts' => 'anything',
'deletedAt' => null,
'formReportId' => factory(FormReport::class)->create()->id,
'formReportId' => FormReport::factory()->create()->id,
'handlingTime' => '2018-11-16 02:46:00',
'parentId' => factory(Accident::class)->create()->id,
'parentId' => Accident::factory()->create()->id,
'patientId' => $patient->id,
'refNum' => 'test',
'symptoms' => 'aaa',
Expand Down Expand Up @@ -253,30 +253,30 @@ public function testCreateWithAccidentDataOnly4(): void

public function testCreateWithAccidentDataOnly5(): void
{
$patient = factory(Patient::class)->create();
$patient = Patient::factory()->create();
$data = [
'accident' => [
'accidentStatusId' => (new AccidentStatusService())->getNewStatus()->getAttribute('id'),
'accidentTypeId' => factory(AccidentType::class)->create()->id,
'accidentTypeId' => AccidentType::factory()->create()->id,
'address' => 'any',
'assistantId' => factory(Assistant::class)->create()->id,
'assistantId' => Assistant::factory()->create()->id,
'assistantRefNum' => 'ref---',
'caseableId' => factory(DoctorAccident::class)->create()->id,
'caseableId' => DoctorAccident::factory()->create()->id,
'caseableType' => 'doctor',
'cityId' => factory(City::class)->create()->id,
'cityId' => City::factory()->create()->id,
'closedAt' => null,
'contacts' => 'anything',
'deletedAt' => null,
'formReportId' => factory(FormReport::class)->create()->id,
'formReportId' => FormReport::factory()->create()->id,
'handlingTime' => '2018-11-16 02:46:00',
'parentId' => factory(Accident::class)->create()->id,
'parentId' => Accident::factory()->create()->id,
'patientId' => $patient->id,
'refNum' => 'test',
'symptoms' => 'aaa',
'title' => 'ccc',
'assistantPaymentId' => factory(Payment::class)->create()->id,
'incomePaymentId' => factory(Payment::class)->create()->id,
'caseablePaymentId' => factory(Payment::class)->create()->id,
'assistantPaymentId' => Payment::factory()->create()->id,
'incomePaymentId' => Payment::factory()->create()->id,
'caseablePaymentId' => Payment::factory()->create()->id,
]
];
$response = $this->sendPost('/api/director/cases', $data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CasesControllerSearchActionTest extends TestCase

public function testSearch(): void
{
factory(Accident::class, 7)->create();
Accident::factory()->count(7)->create();
$response = $this->sendPost('/api/director/cases/search', []);

$response->assertStatus(200)->assertJson([
Expand Down
Loading

0 comments on commit d6b60f5

Please sign in to comment.