From 946e06c5c58d2b95389351a5e374a4a6483367f9 Mon Sep 17 00:00:00 2001 From: Jonatas Souza Date: Tue, 5 Dec 2023 00:22:38 -0300 Subject: [PATCH] setting up codeception/laravel module and laravel package testings --- .github/workflows/ci.yml | 3 ++ codeception.dist.yml | 3 ++ composer.json | 7 +++-- routes/laravel.route.php | 4 +-- tests/_data/blade/endpoint.png | Bin 0 -> 1780 bytes .../BootstrapComponentCest.php | 27 ++++++++++++++---- 6 files changed, 34 insertions(+), 10 deletions(-) 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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e5805f89ec4f1af03e08187b6fe6c250382f4706 100644 GIT binary patch literal 1780 zcmeAS@N?(olHy`uVBq!ia0y~yVDtiE4kn<;7w<-(00U=%M`SSr1K$x4W}K?cC(XdX zw#?JTF{EP7+q(xREjANzxM(r;|No~a^`?fJPf7h)QhToI6x*4lTPrf+>i_-u$*uA0 z_e*95JJ)*?RP#?vGEX@vz3B;Woxp=KGK6 zdwoYO@z|ZmzjWQK*~Ytf9X!-s^K>y!)c*``ygim$(2sB;e8uSh}g^+v#|znAK_rNn>i7Jokb zdD-o}=X;-otuU*+*!lZFe4y?6;>bBzf(vHE>y0yu@0sTwE57y7!0P?uxS2P0n*Uy? z+gnwedgWkE6Ct0!o6~ydTkP!iX#TnCu}LTYz2)A&I`_*N%lFZfyeioCoqZ&OC(7D_ z9+#b~Fh1-4DXwVun>mSP_4ALuFP(_j&V5PG?#S)6x6ae6eZKF@<$bTOiJv|D`}Fr~ z_ofB^kV-1#!<9ZhwXNyr0mf9ZjOp_|Hw%j&aIf7}f9CeNxt9Br9>)Ayah>09kAApq zHe1}`V)?~l&+()=DcdQ#ip@SBvAhtkYqK)*y`ax-^EAG7bt>;OjjtX*tA2h@__rHB zl$pQRtS-8Suh3ts!Ha^`=|{d_6$a+=oau-NB+ zs~6rs_j`xsy~b&OTCCT9K9~MtVgJ{eu@QI^P-*s#^9M37t@!!B_4|!;ju&(9m%diA z-+cb(v*RwG()VTD%K5f_oy-P%V{!ZmQQ3Lr{hV8Sp8VUp^}fklrZ|(&8?L`E-uKp7 z?3T@Qo3~fHg?)FohDBD#;q_9Keeu35|2LWQH(%Id`62Z4TI=U2%VQ6R*4eIq{@pUY zIrRIxXU8?H@jB&nfY$UGmbMpPUwiTCb?N*2^|Kq-um6)(ynXRG+w*u+^!D^~`zyay z+;&K_*i?P$bV*Lae`bEoGkBfc78HKV z=J1}}|Ib>Vmja8gb?cPgFZ8<;J|`1zxs$39c;0B8e-ium@47kHpOw3=nqJlU=P2IrxdtpH_m}m*YgDg$I$_o3 znauTlXZHjZZOHvSXMIp@Ur#FDoIl;tamAbP0l+XkKGRKQX literal 0 HcmV?d00001 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