Skip to content

Instantly share code, notes, and snippets.

View devmsh's full-sized avatar
👨‍💻
Available for new projects

Mohammed S Shurrab devmsh

👨‍💻
Available for new projects
View GitHub Profile
@devmsh
devmsh / ioc.php
Last active June 19, 2017 12:01 — forked from akramabdulrahman/index.php
IoC implementation
<?php
class B
{
public $name = 'akram';
}
class A
{
private $b;
<?php
class Container
{
public function make($className){}
public function register($className, $callback){}
}
// initialize the container and register some classes
@devmsh
devmsh / TestCase.php
Created May 2, 2018 09:18
quicker Laravel Passport test using fake token generator
<?php
abstract class TestCase extends BaseTestCase{
public function mockPassportToken(): void
{
$factory = \Mockery::mock(PersonalAccessTokenFactory::class);
$factory->shouldReceive('make')->with(\Mockery::any(), \Mockery::any(), \Mockery::any())->andReturn(new PersonalAccessTokenResult("123", "123"));
app()->instance(PersonalAccessTokenFactory::class, $factory);
}
}
@devmsh
devmsh / with.java
Created May 13, 2018 19:24
Android with|without Databinding
package app.com.datrios.activities;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import com.jaeger.library.StatusBarUtil;
@devmsh
devmsh / UserUpdateTest.php
Last active December 11, 2018 11:41
UserUpdateTest
<?php
class UserUpdateTest extends TestCase
{
use DatabaseMigrations;
public function test_user_can_update_profile()
{
Notification::fake();
Passport::actingAs($user = factory(User::class)->create());
@devmsh
devmsh / UserUpdateTest.php
Created December 11, 2018 12:13
UserUpdateTest2.php
<?php
class UserUpdateTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->migrate([
self::DATABASE_MIGRATIONS_USER,
@devmsh
devmsh / TestCase.php
Created December 11, 2018 12:13
TestCase migrate
<?php
abstract class TestCase extends BaseTestCase
{
const DATABASE_MIGRATIONS_USER = "database/migrations/user";
/**
* @param $path
*/
public function migrate($path)
@devmsh
devmsh / CreateEventsTable.php
Created December 11, 2018 12:15
CreateEventsTable
<?php
class CreateEventsTable extends Migration
{
public function up()
{
Schema::create('events', function (Blueprint $table) {
// table columns
$table->unsignedInteger('user_id');
@devmsh
devmsh / User.php
Last active December 18, 2018 12:21
User.php
<?php
class User {
public function addNewMobile($mobile): UserMobile
{
User::where('mobile', $mobile)->where('status',self::STATUS_NOT_VERIFIED)->delete();
$this->activationCodes()->where('mobile', $mobile)->delete();
@devmsh
devmsh / MultipleMobileTest.php
Created December 18, 2018 12:46
MultipleMobileTest.php
<?php
class MultipleMobileTest extends TestCase
{
public function test_user_can_add_new_mobile()
{
$unverifiedUser = $this->newUnverifiedUser([
'mobile' => '970567940999'
]);