Getting Lumen to talk to Codeception - php

A colleague of mine is having an issue trying to get a Lumen module working for Codeception. He has added some notes here:
https://laracasts.com/discuss/channels/lumen/codeception-lumen-module
He is trying to create a Lumen module for Codeception based on the Laravel5 module, without success. Laravel implements an HttpKernel but Lumen does not, it appears that the http kernel translates Laravel's requests for codeception tests, so attempting to run the tests without initializing the http kernel doesn't work.
It may be the case that we need to use the Symfony Http\Kernel rather than the Laravel one, in which case how do we initialize that kernel module from codeception?
Has anyone else done any work towards getting Codeception tests running with Lumen?

I've forked that current project and I believe I may have a working copy of this package.
https://github.com/jerairrest/codeception-lumen
Take a gander. I've also put in for a pull request but I haven't got a response from the original maintainer.
Cheers!
Jer

Related

Github workflow to run test on Magento module repo

We are working on a Magento payment module, let's call it ABC. We are using Docker for the development. So, for development, we are using a Magento image and adding the module code to the htdocs/app/code via volumes from docker-compose.yml. Our Github repo contains the module code only. We have added some tests for the module under app/code/ABC/Payment/Test folder. We want to setup a Github workflow that will run the test automatically on pull request.
The issue is some of the code depends on the Magento core classes like Magento\Framework\App\Config\ScopeConfigInterface, Magento\Store\Model\StoreManagerInterface and so on which won't be available in our Github repo. Is there any Github actions with which we can setup Magento, copy the module codes into it and run the module's tests?
Any help would be greatly appreciated. We are unable to figure this out.
You could require magento using composer within your github workflow. https://github.com/marketplace/actions/composer-php-actions
If you use grumphp (https://github.com/phpro/grumphp) you can have a look at this example: https://github.com/phpro/phpro-mage2-module-translations/blob/master/.github/workflows/grumphp.yml
You have not shared much about what precisely is making you unable to figure it out for Github Actions, however reading your question it looks to me like you already have figured out for development: Using Docker.
Now Github Actions as well supports Docker. All you need is to run the setup script for the development environment that establishes that Docker setup within the Github Action before running your tests.
You may want to add an additional environment for it, so that you can branch between the development system and Github Actions, but theoretically it should already work without.
Then after you have cloned the code, and then setup the Docker environment, execute the tests in the Github Action. The tests should run now.

Laravel 5 - Can I use a Facade within a service provider without registering it?

I'm currently developing a set of packages/service providers to use as a sort of boilerplate for new web applications. I started developing some time ago and I never ran the packages through composer.
After I made a repository and added the package to a new Laravel application, it installed just fine, until it ran php artisan package:discover. The error was:
In breadcrumbs.php line 5:
Class 'Athena' not found
and it refers to this line:
Breadcrumbs::register( \Athena::getFacadeRoot()->route_name_prefix . '.dashboard.show', function ( $breadcrumbs ) {
in which \Athena:: is a facade within the package. I fixed the issue by adding the facade to the app.php file. The idea was to bootstrap applications easily, so my question is:
Can I use a facade within a package and still use the Laravel package discovery, without having to edit files when I create a new project?

Can I use laravel5 packages in Lumen?

I was developing REST API's in Laravel5 and now I am moving same project to Lumen due to speed issue.
The problem is,I am using "vsmoraes/laravel-pdf": "1.0.1" in Laravel,Now I want to use the same in Lumen.
How it is possible?
When I am added via composer and trying to access from controller,I am getting following error ,
BindingResolutionException in Container.php line 785:
Target [Vsmoraes\Pdf\Pdf] is not instantiable.
Any idea?
Lumen is a micro-framework based on Laravel. As of that, Lumen does not have all the Laravel featuers (by default).
Most of the packages will have to be updated, so they will have much less Laravel-specific dependencies than they're having now.

Can't run tests provided in Slim Framework

I'm trying to make a simple rest client for my android app. I would like to do than in TDD way, but for that I need simple working configuration for all actions (GET, POST, and so on). After some struggling I was able to make test work with get requests. Unfortunately with Post routes things didn't go well. When testing (netbeans 8.0.2 + phpunit) on local server (xampp 5.6.3) all I get is 404 error. Same thing if I run method being tested with Advanced Rest Client Application (chrome extension). When I send my rest files to live hosting then method in question works as it should.
After searching for some days (read about everything with 404 errors on Slim Framework) I decided to start with something which should work right of the box. Slim framework comes with simple demo app and some tests. Here I have another error which prevents start of tests:
Fatal error: Class 'Slim\Middleware' not found in C:\xampp\htdocs\web\local\codeguy-Slim-04958a1\tests\MiddlewareTest.php on line 3
As far I can tell I have something wrong with my xampp server but I don't have any more ideas how to fix this. So If somebody could show me correct way to setup Netbeans, Xampp, Slim and phpunit(I'm running it from IDE (ALT + F6)) then I would be able to build my rest api on top of that.
I just tried the following, maybe it might suggest a different route to try?
git clone https://github.com/codeguy/Slim.git
cd Slim
// Edit composer.json to include "phpunit/phpunit": "4.3.*"
curl -sS https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit
A few tests failed for me, surprisingly - so that would need digging into. But all classes were found.
Everything should work though, as the project seems to be building OK over on Travis CI.
I've found out what was wrong with my tests and with test provided with framework. I didn't know that I had to set bootstrap.php file in Project configuration of Netbeans.

Custom package service provider cannot be found

I'm trying to develop a custom package using "workbench". It's a simple package that will create a repository to consume a different API we have. I plan on injecting this repository into my controllers of my application. Anyway, I created the package using "workbench". This creates the service provider. The Laravel docs say to add the service provider to my "providers" array in app.config. I've done this, but when I run composer update, I get an error saying that the class is not found, specifically: PHP Fatal error: Class 'MyVendor\MyPackage\ServiceProvider not found in /.. .. .. ../laravel/vendor/framework/src/Illuminate/Foundation/ProviderRepository.php. I thought I followed the docs correctly, what am I missing?
Simply running composer install inside the workbench directory resolves this issue.

Categories