Skip to content

Instantly share code, notes, and snippets.

View aliuwahab's full-sized avatar

Gbeila Aliu Wahab aliuwahab

View GitHub Profile
@aliuwahab
aliuwahab / deployment_guide.md
Created February 2, 2020 12:01 — forked from vicgonvt/deployment_guide.md
Deployment Guide for Ubuntu Server from Scratch with Laravel
@aliuwahab
aliuwahab / EventMockTesting.php
Last active March 11, 2019 09:27
This is just an example test to mock an event class like OrderShipped (not created)
<?php
namespace Tests\Feature;
use App\Jobs\ExampleJob;
use App\User;
use Illuminate\Support\Facades\Bus;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase
{
use RefreshDatabase;
@aliuwahab
aliuwahab / EventMockTesting.php
Created March 11, 2019 09:23
This is an example mock testing an event class in Laravel.
/** @test */
public function test_event_mocking()
{
Event::fake();
// Perform order shipping...
Event::assertDispatched(OrderShipped::class, function ($e) use ($order) {
return $e->order->id === $order->id;
});
@aliuwahab
aliuwahab / ExampleJob.php
Created March 11, 2019 09:20
This an Example Job in Laravel PHP
<?php
namespace App\Jobs;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
class ExampleJob implements ShouldQueue
@aliuwahab
aliuwahab / ExampleTest.php
Last active March 11, 2019 09:12
ExampleTest
<?php
namespace Tests\Feature;
use App\Jobs\ExampleJob;
use App\User;
use Illuminate\Support\Facades\Bus;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ExampleTest extends TestCase
{
use RefreshDatabase;
@aliuwahab
aliuwahab / Helpers.php
Last active February 6, 2019 15:52
A function that accepts a GitHub username, and returns that users "Score" based on the below rules. PushEvent = 10 points. PullRequestEvent = 5 points. IssueCommentEvent = 4 points. Any other event = 1 point
/**
*@Param String username
*/
public function getUserGithubScores($username)
{
//initialise guzzle http client;
$client = new Client();
try {
//make a get request to github
$res = $client->get('https://api.github.com/users/'.$username.'/events/public');