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 / DeleteNotVerifiedUsersTest.php
Created December 19, 2018 22:39
DeleteNotVerifiedUsersTest.php
<?php
class DeleteNotVerifiedUsersTest extends TestCase
{
public function test_can_delete_unverified_user_with_specific_mobile_number()
{
$unverifiedUser = $this->newUnVerifiedUser(["mobile" => "970567940999"]);
$userMobile = factory(UserMobile::class)->create(["mobile" => "970567940999"]);
@devmsh
devmsh / MultipleMobileTest.php
Last active December 19, 2018 22:16
MultipleMobileTest.php
<?php
class MultipleMobileTest extends TestCase
{
public function test_user_can_add_new_mobile()
{
Event::fake([MobileVerifying::class,MobileVerified::class]);
$user = $this->newVerifiedUser();
@devmsh
devmsh / EventServiceProvider.php
Created December 19, 2018 09:48
EventServiceProvider.php
<?php
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
'App\Events\MobileVerifying' => [
'App\Listeners\DeleteNotVerifiedUsers',
'App\Listeners\DeleteOutdatedActivationCodes',
],
@devmsh
devmsh / User.php
Created December 19, 2018 08:56
User.php
<?php
class User{
public function addNewMobile($mobile): UserMobile
{
event(new MobileVerifying($mobile));
$userMobile = $this->mobiles()->create(['mobile' => $mobile, 'status' => self::STATUS_VERIFIED]);
@devmsh
devmsh / EventServiceProvider.php
Created December 19, 2018 08:54
EventServiceProvider.php
<?php
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
'App\Events\MobileVerifying' => [
'App\Listeners\MobileVerifyingListener',
],
@devmsh
devmsh / User.php
Last active December 19, 2018 08:53
User.php
<?php
class User{
public function addNewMobile($mobile): UserMobile
{
$userMobile = new UserMobile(['mobile' => $mobile, 'status' => self::STATUS_VERIFIED]);
if(app()->events->until(
event(new MobileVerifying($userMobile)) !== false
@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'
]);
@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 / 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 / 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)