+ @include('partials.sidebar')
+
+
+
Edit Video
+
+
+ {!! Form::model($video,['method' => 'PATCH', 'route' => ['video.update', $video->id]]) !!}
+ @include('partials.error')
+
+
+ {!! Form::label('link', 'Video URL', ['class' => 'control-label']) !!}
+ {!! Form::url('youtube_link', null, ['class' => 'form-control']) !!}
+
+
+ {!! Form::label('title', 'Title', ['class' => 'control-label']) !!}
+ {!! Form::text('title', null, ['class' => 'form-control']) !!}
+
+
+ {!! Form::label('describe', 'Description', ['class' => 'control-label']) !!}
+ {!! Form::textarea('description', null, ['class' => 'form-control', 'rows' => '5']) !!}
+
+
+ {!! Form::label('category', 'Category', ['class' => 'control-label']) !!}
+
+ @foreach ($categories as $category)
+ id == $video->category_id ? 'selected' : ''}}> {{ $category->title }}
+ @endforeach
+
+
+
+ {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
+
+ {!! Form::close() !!}
+
+
+@endsection
diff --git a/resources/views/videos/index.blade.php b/resources/views/videos/index.blade.php
new file mode 100644
index 0000000..8e12517
--- /dev/null
+++ b/resources/views/videos/index.blade.php
@@ -0,0 +1,20 @@
+@extends('layouts.master')
+
+@section('title', 'My videos')
+
+@section('styles')
+
+ @if (isset($videos, $categories))
+
+ @include('partials.category_list')
+
- .container {
- text-align: center;
- display: table-cell;
- vertical-align: middle;
- }
-
- .content {
- text-align: center;
- display: inline-block;
- }
-
- .title {
- font-size: 96px;
- }
-
-
-
-
-
-
Laravel 5
+
+ @foreach ($videos as $video)
+ @include('partials.video_display')
+ @endforeach
+ {!! $videos->render() !!}
+
+ @else
+
+
Welcome, to soma-tech!
+
A place to learn via YouTube videos .
+
Sorry , currently there are no videos uploaded.
+
Upload a video to start the learning movement.Thank you .
-
-
-
+ @endif
+
+@endsection
diff --git a/server.php b/server.php
index f65c7c4..1b4655b 100644
--- a/server.php
+++ b/server.php
@@ -1,12 +1,10 @@
*/
-
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
diff --git a/tests/AuthenticationTest.php b/tests/AuthenticationTest.php
new file mode 100644
index 0000000..09b48f9
--- /dev/null
+++ b/tests/AuthenticationTest.php
@@ -0,0 +1,45 @@
+visit('auth/register')
+ ->type('Atea Nazhrah', 'name')
+ ->type('ateaN@example.com', 'email')
+ ->type('testing', 'password')
+ ->type('testing', 'confirm-password')
+ ->press('Register')
+ ->seePageIs('/dashboard');
+ }
+
+ /**
+ * Test user can login traditionally.
+ *
+ * @return void
+ */
+ public function testTraditionalLogin()
+ {
+ factory(Soma\User::class)->create([
+ 'email' => 'aloraleigh@example.com',
+ 'password' => bcrypt('testing'),
+ ]);
+
+ $this->visit('auth/login')
+ ->type('aloraleigh@example.com', 'email')
+ ->type('testing', 'password')
+ ->press('Log In')
+ ->seePageIs('/dashboard');
+ }
+}
diff --git a/tests/DashboardTest.php b/tests/DashboardTest.php
new file mode 100644
index 0000000..eddd9ff
--- /dev/null
+++ b/tests/DashboardTest.php
@@ -0,0 +1,160 @@
+create();
+
+ $this->actingAs($user)
+ ->visit('/dashboard')
+ ->see('Dashboard');
+
+ $this->actingAs($user)
+ ->visit('/dashboard')
+ ->see('Edit Profile');
+
+ $this->actingAs($user)
+ ->visit('/dashboard')
+ ->see('My videos');
+ }
+
+ /**
+ * Test the user profile can be seen.
+ *
+ * @return void
+ */
+ public function testUserProfileSeen()
+ {
+ $user = factory(Soma\User::class)->create([
+ 'name' => 'Zaria Zinzi',
+ 'email' => 'zaria@example.com',
+ ]);
+
+ //$this->seeInDatabase('categories', ['title' => 'Abigail']);
+ $this->actingAs($user)
+ ->visit('/dashboard')
+ ->see('Zaria Zinzi')
+ ->see('zaria@example.com');
+ }
+
+ /**
+ * Test the user updated data is saved in the database.
+ *
+ * @return void
+ */
+ public function testUserUpdatedDataSaved()
+ {
+ $user = factory(Soma\User::class)->create();
+
+ $this->actingAs($user)
+ ->visit("profile/{$user->id}/edit")
+ ->type('Zulia Dexa', 'name')
+ ->type('zuliadexa@example.com', 'email')
+ ->press('Update')
+ ->seePageIs('/dashboard');
+
+ $this->seeInDatabase('users', ['email' => 'zuliadexa@example.com']);
+ }
+
+ /**
+ * Test the user can view their own categories.
+ *
+ * @return void
+ */
+ public function testCategoriesBelongingToSelfViewed()
+ {
+ $user = factory(Soma\User::class)->create();
+ $category = factory(Soma\Categories::class, 5)->create([
+ 'user_id' => $user->id,
+ ]);
+
+ $category = factory(Soma\Categories::class)->create([
+ 'user_id' => $user->id,
+ 'title' => 'Tuli',
+ ]);
+
+ $this->actingAs($user)
+ ->visit('category/mycategories')
+ ->see('Tuli');
+ }
+
+ /**
+ * Test the user can add categories.
+ *
+ * @return void
+ */
+ public function testNewCategoriesCreated()
+ {
+ $user = factory(Soma\User::class)->create();
+ factory(Soma\Categories::class, 3)->create([
+ 'user_id' => $user->id,
+ ]);
+
+ $this->actingAs($user)
+ ->visit('category/mycategories')
+ ->press('Add')
+ ->type('Testing', 'title')
+ ->press('Add')
+ ->seePageIs('category/mycategories');
+
+ $this->seeInDatabase('categories', ['title' => 'Testing']);
+ }
+
+ /**
+ * Test the user can edit their own categories.
+ *
+ * 'edit-btn' is the id of the edit button.
+ *
+ * @return void
+ */
+ public function testCategoriesEdited()
+ {
+ $user = factory(Soma\User::class)->create();
+ $category = factory(Soma\Categories::class)->create([
+ 'user_id' => $user->id,
+ 'title' => 'Exalted',
+ ]);
+
+ $this->seeInDatabase('categories', ['title' => 'Exalted']);
+
+ $this->actingAs($user)
+ ->visit("category/{$category->id}/edit")
+ ->see('Exalted')
+ ->type('God is Exalted ', 'title')
+ ->press('Save')
+ ->seePageIs('category/mycategories')
+ ->see('God is Exalted');
+ }
+
+ /**
+ * Test the user can delete their own categories.
+ *
+ * @return void
+ */
+ public function testCategoriesDeleted()
+ {
+ $category = factory(Soma\Categories::class)->create([
+ 'title' => 'Praise',
+ ]);
+
+ $this->seeInDatabase('categories', ['title' => 'Praise']);
+
+ $this->withoutMiddleware();
+ $response = $this->call('DELETE', "/category/$category->id");
+ $this->assertEquals(302, $response->getStatusCode());
+
+ $this->notSeeInDatabase('categories', ['title' => 'Praise']);
+ }
+}
diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php
deleted file mode 100644
index 7e81d37..0000000
--- a/tests/ExampleTest.php
+++ /dev/null
@@ -1,19 +0,0 @@
-visit('/')
- ->see('Laravel 5');
- }
-}
diff --git a/tests/HomeControllerTest.php b/tests/HomeControllerTest.php
new file mode 100644
index 0000000..03e4124
--- /dev/null
+++ b/tests/HomeControllerTest.php
@@ -0,0 +1,43 @@
+call('GET', 'auth/login');
+ $this->assertResponseStatus(200);
+ }
+
+ /**
+ * Test the auth/register route is accessible.
+ *
+ * @return void
+ */
+ public function testRegister()
+ {
+ $this->call('GET', 'auth/register');
+ $this->assertResponseStatus(200);
+ }
+
+ /**
+ * Test the dashboard route is accessible.
+ *
+ * @return void
+ */
+ public function testDashboard()
+ {
+ $this->call('GET', 'dashboard');
+ $this->assertResponseStatus(302);
+ }
+}
diff --git a/tests/HomepageTest.php b/tests/HomepageTest.php
new file mode 100644
index 0000000..0a36db1
--- /dev/null
+++ b/tests/HomepageTest.php
@@ -0,0 +1,73 @@
+visit('/')
+ ->see('Categories');
+ }
+
+ /**
+ * Test the categories lists are clickable.
+ *
+ * @return void
+ */
+ public function testCategoriesListsCanBeClicked()
+ {
+ factory(Soma\Categories::class)->create([
+ 'title' => 'Abigail',
+ ]);
+
+ $this->seeInDatabase('categories', ['title' => 'Abigail']);
+
+ $category_id = factory(Soma\Categories::class)->create([
+ 'title' => 'Osuofia',
+ ])->id;
+
+ $this->visit('/')
+ ->click('Osuofia')
+ ->seePageIs("categories/{$category_id}/videos");
+ }
+
+ /**
+ * Test $videos and $categories variables returned to view.
+ *
+ * @return void
+ */
+ public function testVariablesReturnedToView()
+ {
+ factory(Soma\Categories::class, 5)->create();
+ factory(Soma\Videos::class, 5)->create();
+
+ $this->call('GET', '/');
+ $this->assertViewHasAll(['videos', 'categories']);
+ }
+
+ /**
+ * Test videos are paginated.
+ *
+ * @return void
+ */
+ public function testVideosPaginated()
+ {
+ factory(Soma\Videos::class, 24)->create();
+
+ $results = Videos::paginate(6);
+
+ $this->assertEquals(6, $results->perPage());
+ }
+}
diff --git a/tests/VideosTest.php b/tests/VideosTest.php
new file mode 100644
index 0000000..4b6c99f
--- /dev/null
+++ b/tests/VideosTest.php
@@ -0,0 +1,151 @@
+create();
+ $category = factory(Soma\Categories::class)->create();
+
+ $this->actingAs($user)
+ ->visit('video/create')
+ ->type('https://www.youtube.com/embed/qVM7cwqGTTU&index=4&list=RDH1XrbuOoKFw', 'youtube_link')
+ ->type('I will worship you', 'title')
+ ->type('Gospel worship video', 'description')
+ ->select($category->id, 'category_id')
+ ->press('Add');
+
+ $this->seeInDatabase('videos', ['title' => 'I will worship you']);
+ }
+
+ /**
+ * Test the user can see their uploaded videos.
+ *
+ * @return void
+ */
+ public function testPersonallyUploadedVideosViewed()
+ {
+ $user = factory(Soma\User::class)->create();
+ $category = factory(Soma\Categories::class)->create();
+
+ factory(Soma\Videos::class, 3)->create([
+ 'category_id' => $category->id,
+ 'user_id' => $user->id,
+ ]);
+
+ factory(Soma\Videos::class)->create([
+ 'category_id' => $category->id,
+ 'user_id' => $user->id,
+ 'youtube_link' => 'https://www.youtube.com/embed/6R0YdAnASc8&index=23&list=RDH1XrbuOoKFw',
+ 'title' => 'MERCY SAID NO!',
+ 'description' => 'Judy Jacobs sings MERCY SAID NO!',
+ ]);
+
+ $this->actingAs($user)
+ ->visit('video/myvideos')
+ ->see('MERCY SAID NO!');
+ }
+
+ /**
+ * Test the videos can be edited.
+ *
+ * @return void
+ */
+ public function testVideosEdited()
+ {
+ $user = factory(Soma\User::class)->create();
+ $category = factory(Soma\Categories::class)->create();
+
+ $video = factory(Soma\Videos::class)->create([
+ 'category_id' => $category->id,
+ 'user_id' => $user->id,
+ 'youtube_link' => 'https://www.youtube.com/embed/6R0YdAnASc8&index=23&list=RDH1XrbuOoKFw',
+ 'title' => 'MERCY SAID NO!',
+ 'description' => 'Judy Jacobs sings MERCY SAID NO!',
+ ]);
+
+ $this->actingAs($user)
+ ->visit("video/{$video->id}/edit")
+ ->see('MERCY SAID NO!')
+ ->type('Gospel - Mercy Said No!', 'title')
+ ->type('Mercy Said No song as sang by Judy Jacobs', 'description')
+ ->press('Save');
+
+ $this->seeInDatabase(
+ 'videos',
+ [
+ 'title' => 'Gospel - Mercy Said No!',
+ 'description' => 'Mercy Said No song as sang by Judy Jacobs',
+ ]
+ );
+ }
+
+ /**
+ * Test the videos can be deleted.
+ *
+ * @return void
+ */
+ public function testVideosDeleted()
+ {
+ $user = factory(Soma\User::class)->create();
+ $category = factory(Soma\Categories::class)->create();
+
+ $video = factory(Soma\Videos::class)->create([
+ 'category_id' => $category->id,
+ 'user_id' => $user->id,
+ 'youtube_link' => 'https://www.youtube.com/embed/z3wwWFsSlNQ&list=RDH1XrbuOoKFw&index=27',
+ 'title' => 'Still - Hillsong United with Lyrics!',
+ 'description' => "Appreciating God's love for us as Jesus died on the cross to save our souls",
+ ]);
+
+ $this->withoutMiddleware();
+ $response = $this->call('DELETE', "/video/$video->id");
+ $this->assertEquals(302, $response->getStatusCode());
+
+
+ $this->notSeeInDatabase(
+ 'videos',
+ [
+ 'title' => 'Still - Hillsong United with Lyrics!',
+ 'description' => "Appreciating God's love for us as Jesus died on the cross to save our souls",
+ ]
+ );
+ }
+
+
+ /**
+ * Test a video can be viewed on its own page.
+ *
+ * @return void
+ */
+ public function testSingleVideoViewed()
+ {
+ $user = factory(Soma\User::class)->create();
+ $category = factory(Soma\Categories::class)->create();
+
+ $video = factory(Soma\Videos::class)->create([
+ 'category_id' => $category->id,
+ 'user_id' => $user->id,
+ 'youtube_link' => 'https://www.youtube.com/embed/gIPMllUV12o&list=RDH1XrbuOoKFw&index=27',
+ 'title' => 'My life is in your hands',
+ 'description' => "Kirk Franklin's Gospel song,"
+ ]);
+
+ $this->actingAs($user)
+ ->visit('video/myvideos')
+ ->see('My life is in your hands')
+ ->click('More Info')
+ ->seePageIs("video/{$video->id}");
+ }
+}