diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9481819..b61f6b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/codeception.dist.yml b/codeception.dist.yml index 3d9aa9b..9f0b0bb 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -17,6 +17,9 @@ modules: Yii2: configFile: 'tests/_app/config/test.php' cleanup: false + Laravel: + root: 'tests/_laravel/' + cleanup: false coverage: enabled: true whitelist: diff --git a/composer.json b/composer.json index 4f4ff6f..f8829cc 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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": { diff --git a/routes/laravel.route.php b/routes/laravel.route.php index d8f47a1..e3c0ee8 100644 --- a/routes/laravel.route.php +++ b/routes/laravel.route.php @@ -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'); }); \ No newline at end of file diff --git a/tests/_data/blade/endpoint.png b/tests/_data/blade/endpoint.png index e69de29..e5805f8 100644 Binary files a/tests/_data/blade/endpoint.png and b/tests/_data/blade/endpoint.png differ diff --git a/tests/laravel-functional/BootstrapComponentCest.php b/tests/laravel-functional/BootstrapComponentCest.php index 342c998..0119bac 100644 --- a/tests/laravel-functional/BootstrapComponentCest.php +++ b/tests/laravel-functional/BootstrapComponentCest.php @@ -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); } } \ No newline at end of file