Manually run your Bitbucket Pipelines

In the earlier post, we have talked about how to test your Laravel  application with Bitbucket Pipelines, but sometimes you may need to run the tests on specific commit and not after you push it, luckily for us Bitbucket Pipelines team has implemented the custom section in the ymal file, which helps us to do so.

It does not differ that much from what we already have, so adding the following to our file which we created in the earlier  post will enable us to manually run the pipeline:

Continue reading

Filed under: Code, docker, PHP

How to test your Laravel application with Bitbucket Pipelines

Bitbucket Pipelines is a CI service that you can use to test your application, yes it has its own limitation, but remember it is still new and hopefully it will get better. Today I had the chance to work with it, and trust me I was not planning to do so, am a happy Gitlab-ci user, but why not.

Each of these service has its pros and cons, and am not planning to go over it and list it, just do a small reading to find the differences, so today I’ll talk about how to test your Laravel Application with Bitbucket Pipelines and how you can get it fast.

Requirements:

For sure you need to know Laravel and how to write tests, this post will not talk about it, and it would be nice if you know a little bit of Docker.

Enabling Pipelines:

You will need to enable the pipelines from the Repository Settings as the following image

Continue reading

Filed under: Code, docker, Laravel, PHP

There is no shame of asking questions

So, as a programmer do you feel ashamed of asking questions? and let us say that you are new to programming, do you care about that?

The most important thing that I have found over the past few days is that newcomers to programming feel scared of how the community will react to them when you ask a question, a stupid question or even any question. So why we don’t make it simple, why we always laugh on each and every question we got?

Maybe am so lucky to not feel ashamed of asking questions, even if I found out the solution by myself or even I found out that the approach that I have taken was not correct, and sometimes the APPS that am using caused it. And this is something that happened to me in the past two days, I was pulling my hair from not being able to work with Lumen via PUT request, and I was angry talking about it, pinging everyone and even complained about it on twitter, to find out finally that Postman was not sending the correct header. and before anyone jumps and says that I should write tests, that’s what I was doing, I wrote tests and they failed too when I tried $this->pull function that comes with Lumen Test case class, which caused a lot of running around and trying it and even try to debug each and every call I made to the API, and I finally fixed it by creating an ajax call $this->ajax with the type PUT to the same API endpoint.

To find out later that the problem mostly comes from Postman, and for some magical reason, even my tests started to pass.

I even got some funny reactions from some people on the IRC, someone even started to argue with me that Laravel IRC channel is not for Lumen questions and that Lumen codebase is not related to Laravel .. etc, another one didn’t want to help because I didn’t answer his question, why am using Lumen, or I think it was what I was trying to do, even though I have answered his question, trying to use PUT requests to update database record.

Now let us imagine that a new programmer was asking those questions, and everyone mocked him, do you think he will feel confident? and he will keep asking questions and learn? if we got him to think that asking questions is a shame and you should already know the answers. It’s already a hard thing for a new programmer, they already have a hard time following us all, and try to figure out how they can learn new things, as each day we have a new thing. Trust me I do have a problem following up all those new trends.

So let’s make it easier and start to enhance our communication skills, no need to mock someone just because you are better than him, or because you are a core contributor to the project, we are all human. and based on what I know no one was ever born fully educated.

 

Filed under: Other, Personal

When you cant focus

In the past few weeks/months, I didn’t have my focus on one specific thing, I was doing multiple things at the same time, I tried to study English to improve it and have better score, I tried to read more about PHP (as each day pass I feel that am losing and forgetting everything I used to know once about PHP), and Finally I was also reading and trying to expand my knowledge for Docker.

I know that this is not a normal situation, but things are not getting any easier, every day a new thing to deal with, a new problem or a more complicated situation to think about and try to figure a solution for it, many I can’t do much as it is out of my control.

I always said and keep saying that am not a real programmer for many reasons, I didn’t study computer engineering nor computer science, I studied Information Technology which has some interaction with programming, but not as deep as computer science for example, and this is one of the reasons why I don’t stop reading books about programming, I always feel that there is something missing that I don’t fully know so I need to search and try to figure it out.

And many times sadly, I spend a lot of money on books that I don’t have time to read or resources that I found not as useful as I thought it would be for me. Which sadly leaves me with too much time to spend with the family. and am so lucky to have family/wife who supports me, and supports my premonition of reading and filling the gaps.

But this does not make me less than any good programmer out there, which is something I know, but I always try to forget and pretend that am not that good, so I keep doing what I do best, annoy everyone around me with my premonition.

Right now I have a lot of things to do, and so little time to do them all, but am trying, maybe not my best yet, and not sure when my best will come out, but at least am still trying and don’t want to stop.

So what’s next, I have no idea, but I know that I need to fix my English and try to understand the new terms in the PHP world that everyone is using nowadays.

Sometimes when you spend too much time working on one project, you will lose touch with the outside world as your focus will be to get the project done correctly, not in the fancy way that every new term likes to shine.

Anyway, it’s me talking before going to bed, so am sure none of what I have just said will make any sense.

Filed under: Books, Personal

Testing upload file with Slim 3 (a better way)

In my last article, I talked about how we can mock the upload functionality, but without testing the existing of the file, this will work with you without any problem, but now to test the existence of the file we can do it like this:

This is the content of the upload function from the upload controller:

As you can see nothing too fancy, we get the uploaded files, we check that the upload worked then we moved the file to the storage directory, now the testing for the functionality with a real file will be like this:Continue reading

Filed under: Code, PHP