Skip to content

Commit

Permalink
Configurações para executar testes em Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosurita committed Apr 1, 2024
1 parent 38c6d63 commit 892c5f3
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 11 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI
on:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3

- name: Build and test
run: |
docker-compose up -d
make test
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ bash-db:
build:
docker-compose build web

restart:
docker-compose restart
restart: down up

test:
docker-compose exec web bash -c "./vendor/bin/phpunit"

help:
@echo "Available commands:"
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
- "8080:80"
volumes:
- .:/var/www/localhost/htdocs
environment:
- XDEBUG_MODE=coverage
depends_on:
- db
db:
Expand Down
17 changes: 8 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<file>./app/Config/Routes.php</file>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
<!-- <clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/logs/html"/>
<php outputFile="build/logs/coverage.serialized"/>
<php outputFile="build/logs/coverage.serialized"/> -->
<text outputFile="php://stdout" showUncoveredFiles="false"/>
</report>
</coverage>
Expand All @@ -37,21 +37,20 @@
<junit outputFile="build/logs/logfile.xml"/>
</logging>
<php>
<server name="app.baseURL" value="http://example.com/"/>
<server name="app.baseURL" value="http://localhost:8080/"/>
<!-- Directory containing phpunit.xml -->
<const name="HOMEPATH" value="./"/>
<!-- Directory containing the Paths config file -->
<const name="CONFIGPATH" value="./app/Config/"/>
<!-- Directory containing the front controller (index.php) -->
<const name="PUBLICPATH" value="./public/"/>
<!-- Database configuration -->
<!-- Uncomment to provide your own database for testing
<env name="database.tests.hostname" value="localhost"/>
<env name="database.tests.database" value="tests"/>
<env name="database.tests.username" value="tests_user"/>
<env name="database.tests.hostname" value="vl-db"/>
<env name="database.tests.database" value="visao_libertaria_test"/>
<env name="database.tests.username" value="root"/>
<env name="database.tests.password" value=""/>
<env name="database.tests.DBDriver" value="MySQLi"/>
<env name="database.tests.DBPrefix" value="tests_"/>
-->
<env name="database.tests.DBPrefix" value=""/>

</php>
</phpunit>
File renamed without changes.
File renamed without changes.
60 changes: 60 additions & 0 deletions tests/unit/Helpers/MonthHelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

use CodeIgniter\Test\CIUnitTestCase;

class MonthHelperTest extends CIUnitTestCase
{
public function setUp(): void
{
parent::setUp();
helper('month_helper');
}

public function testMonthTranslation(): void
{
$this->assertEquals('Janeiro', month_helper('january'));
$this->assertEquals('Fevereiro', month_helper('february'));
$this->assertEquals('Março', month_helper('march'));
$this->assertEquals('Abril', month_helper('april'));
$this->assertEquals('Maio', month_helper('may'));
$this->assertEquals('Junho', month_helper('june'));
$this->assertEquals('Julho', month_helper('july'));
$this->assertEquals('Agosto', month_helper('august'));
$this->assertEquals('Setembro', month_helper('september'));
$this->assertEquals('Outubro', month_helper('october'));
$this->assertEquals('Novembro', month_helper('november'));
$this->assertEquals('Dezembro', month_helper('december'));
}

public function testMonthTranslationWithSize(): void
{
$this->assertEquals('Jan', month_helper('january', 3));
$this->assertEquals('Fev', month_helper('february', 3));
$this->assertEquals('Mar', month_helper('march', 3));
$this->assertEquals('Abr', month_helper('april', 3));
$this->assertEquals('Mai', month_helper('may', 3));
$this->assertEquals('Jun', month_helper('june', 3));
$this->assertEquals('Jul', month_helper('july', 3));
$this->assertEquals('Ago', month_helper('august', 3));
$this->assertEquals('Set', month_helper('september', 3));
$this->assertEquals('Out', month_helper('october', 3));
$this->assertEquals('Nov', month_helper('november', 3));
$this->assertEquals('Dez', month_helper('december', 3));
}

public function testMonthTranslationWithUcfirst()
{
$this->assertEquals('janeiro', month_helper(mes: 'january', ucfirst: false));
$this->assertEquals('fevereiro', month_helper(mes: 'february', ucfirst: false));
$this->assertEquals('março', month_helper(mes: 'march', ucfirst: false));
$this->assertEquals('abril', month_helper(mes: 'april', ucfirst: false));
$this->assertEquals('maio', month_helper(mes: 'may', ucfirst: false));
$this->assertEquals('junho', month_helper(mes: 'june', ucfirst: false));
$this->assertEquals('julho', month_helper(mes: 'july', ucfirst: false));
$this->assertEquals('agosto', month_helper(mes: 'august', ucfirst: false));
$this->assertEquals('setembro', month_helper(mes: 'september', ucfirst: false));
$this->assertEquals('outubro', month_helper(mes: 'october', ucfirst: false));
$this->assertEquals('novembro', month_helper(mes: 'november', ucfirst: false));
$this->assertEquals('dezembro', month_helper(mes: 'december', ucfirst: false));
}
}

0 comments on commit 892c5f3

Please sign in to comment.