Skip to content

Commit

Permalink
setting up codeception/laravel module and laravel package testings
Browse files Browse the repository at this point in the history
  • Loading branch information
2amjsouza committed Dec 5, 2023
1 parent dff3870 commit 946e06c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
- name: Install dependencies
run: composer install

- name: Install laravel dependencies (testings purpose)
run: (cd ./tests/_laravel && composer install)

- name: Run unit tests
run: ./vendor/bin/codecept run --coverage --coverage-xml ./coverage.xml

Expand Down
3 changes: 3 additions & 0 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ modules:
Yii2:
configFile: 'tests/_app/config/test.php'
cleanup: false
Laravel:
root: 'tests/_laravel/'
cleanup: false
coverage:
enabled: true
whitelist:
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
"ext-gd": "*",
"ext-simplexml": "*",
"bacon/bacon-qr-code": "^2.0",
"khanamiryan/qrcode-detector-decoder": "^1.0",
"illuminate/support": "^10.29"
"khanamiryan/qrcode-detector-decoder": "^1.0"
},
"require-dev": {
"roave/security-advisories": "dev-master",
Expand All @@ -51,7 +50,9 @@
"yiisoft/yii2": "^2.0",
"codeception/module-filesystem": "^1.0",
"codeception/module-yii2": "^1.0",
"codeception/module-asserts": "^1.1"
"codeception/module-asserts": "^1.1",
"codeception/module-laravel": "^2.1",
"laravel/framework": "^8.83"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions routes/laravel.route.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
use Illuminate\Support\Facades\Route;
use Da\QrCode\Controllers\LaravelResourceController;

Route::prefix('da-qrcode')->group(function() {
Route::get('/build', LaravelResourceController::class);
Route::prefix('da-qrcode')->name('da-qrcode.')->group(function() {
Route::get('/build', LaravelResourceController::class)->name('build');
});
Binary file modified tests/_data/blade/endpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 22 additions & 5 deletions tests/laravel-functional/BootstrapComponentCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,29 @@

class BootstrapComponentCest
{
// tests
public function itWorks(FunctionalTester $I)
public function assertEndpointWorks(FunctionalTester $I)
{
$I->wantTo('Assert endpoint works for qrcode creation');
$I->amGoingTo('Call endpoint');
$I->amOnRoute('/da-qrcode/build?content=2am. Technologies');
$I->seeInSource('asd');
$I->amOnRoute('da-qrcode.build', ['content' => '2am. Technologies']);

$qrCode = file_get_contents(codecept_data_dir('blade/endpoint.png'));
$I->seeInSource($qrCode);

$I->amOnRoute('da-qrcode.build', [
'content' => '2am. Technologies 500x500',
'size' => 500
]);

$qrCode = file_get_contents(codecept_data_dir('blade/endpoint2.png'));
$I->seeInSource($qrCode);

$I->amOnRoute('da-qrcode.build', [
'content' => '2am. Technologies 500x500',
'margin' => 50
]);
$source = $I->grabPageSource();
file_put_contents(codecept_data_dir('blade/endpoint3.png'), $source);
$qrCode = file_get_contents(codecept_data_dir('blade/endpoint3.png'));
$I->seeInSource($qrCode);
}
}

0 comments on commit 946e06c

Please sign in to comment.