From 52db350de16f1d6a53e426f7617e78d89123206d Mon Sep 17 00:00:00 2001 From: sanjuktaghosh7 Date: Wed, 22 Jun 2022 18:21:29 +0530 Subject: [PATCH] Classroom Unit Test --- .../snippets/test/ClassroomAddTeacherTest.php | 17 ++--------------- .../test/ClassroomBatchAddStudentsTest.php | 17 ++--------------- .../test/ClassroomCreateCourseTest.php | 12 +----------- .../test/ClassroomEnrollAsStudentTest.php | 15 +-------------- .../snippets/test/ClassroomGetCourseTest.php | 14 ++------------ .../test/ClassroomListAllCoursesTest.php | 16 ++-------------- .../test/ClassroomPatchCourseTest.php | 19 ++----------------- .../test/ClassroomUpdateCourseTest.php | 15 +++------------ 8 files changed, 15 insertions(+), 110 deletions(-) diff --git a/classroom/snippets/test/ClassroomAddTeacherTest.php b/classroom/snippets/test/ClassroomAddTeacherTest.php index 04bf6f4..e721473 100644 --- a/classroom/snippets/test/ClassroomAddTeacherTest.php +++ b/classroom/snippets/test/ClassroomAddTeacherTest.php @@ -20,25 +20,12 @@ class ClassroomAddTeacherTest extends \PHPUnit\Framework\TestCase { - protected function getService() - { - $client = new Google\Client(); - $client->useApplicationDefaultCredentials(); - $client->addScope("https://www.googleapis.com/auth/classroom.courses"); - $service = new Google_Service_Classroom($client); - return $service; - } - + public function testcreateCourseAlias() - { - - $service = $this->getService(); - $classroomResponse = addTeacher($service, '531365794650' ,'gduser2@workspacesamples.dev'); + $classroomResponse = addTeacher('531365794650','gduser2@workspacesamples.dev'); $this->assertNotNull($classroomResponse, "Not get any value from service"); } - - } diff --git a/classroom/snippets/test/ClassroomBatchAddStudentsTest.php b/classroom/snippets/test/ClassroomBatchAddStudentsTest.php index 04f5228..38d2491 100644 --- a/classroom/snippets/test/ClassroomBatchAddStudentsTest.php +++ b/classroom/snippets/test/ClassroomBatchAddStudentsTest.php @@ -20,23 +20,10 @@ class ClassroomBatchAddStudentsTest extends \PHPUnit\Framework\TestCase { - protected function getService() - { - $client = new Google\Client(); - $client->useApplicationDefaultCredentials(); - $client->addScope("https://www.googleapis.com/auth/classroom.courses"); - $service = new Google_Service_Classroom($client); - return $service; - } - public function testcreateCourseAlias() - { - - $service = $this->getService(); - $classroomResponse = batchAddStudents($service, '531365794650', ['a', 'b']); - $this->assertNotNull($classroomResponse, "Not get any value from service"); - + $classroomResponse = batchAddStudents('123456',['a', 'b']); + $this->assertNotNull($classroomResponse, "Not get any value from service"); } diff --git a/classroom/snippets/test/ClassroomCreateCourseTest.php b/classroom/snippets/test/ClassroomCreateCourseTest.php index c44ab12..93e9318 100644 --- a/classroom/snippets/test/ClassroomCreateCourseTest.php +++ b/classroom/snippets/test/ClassroomCreateCourseTest.php @@ -20,21 +20,11 @@ class ClassroomCreateCourseTest extends \PHPUnit\Framework\TestCase { - protected function getService() - { - $client = new Google\Client(); - $client->useApplicationDefaultCredentials(); - $client->addScope("https://www.googleapis.com/auth/classroom.courses"); - $service = new Google_Service_Classroom($client); - return $service; - } public function testCreateCourse() { - $classroomResponse = createCourse(getService()); + $classroomResponse = createCourse(); $this->assertNotNull($classroomResponse, "Not get any value from service"); } - - } diff --git a/classroom/snippets/test/ClassroomEnrollAsStudentTest.php b/classroom/snippets/test/ClassroomEnrollAsStudentTest.php index 23213cb..f8563d1 100644 --- a/classroom/snippets/test/ClassroomEnrollAsStudentTest.php +++ b/classroom/snippets/test/ClassroomEnrollAsStudentTest.php @@ -20,23 +20,10 @@ class ClassroomEnrollAsStudentTest extends \PHPUnit\Framework\TestCase { - protected function getService() - { - $client = new Google\Client(); - $client->useApplicationDefaultCredentials(); - $client->addScope("https://www.googleapis.com/auth/classroom.courses"); - $service = new Google_Service_Classroom($client); - return $service; - } - public function testcreateCourseAlias() - { - - $service = $this->getService(); - $classroomResponse = enrollAsStudent($service, '531365794650' ,'gduser1@workspacesamples.dev'); + $classroomResponse = enrollAsStudent( '123456','abcdef'); $this->assertNotNull($classroomResponse, "Not get any value from service"); - } diff --git a/classroom/snippets/test/ClassroomGetCourseTest.php b/classroom/snippets/test/ClassroomGetCourseTest.php index 15f2a6d..94b300d 100644 --- a/classroom/snippets/test/ClassroomGetCourseTest.php +++ b/classroom/snippets/test/ClassroomGetCourseTest.php @@ -20,21 +20,11 @@ class ClassroomGetCourseTest extends \PHPUnit\Framework\TestCase { - protected function getService() - { - $client = new Google\Client(); - $client->useApplicationDefaultCredentials(); - $client->addScope("https://www.googleapis.com/auth/classroom.courses"); - $service = new Google_Service_Classroom($client); - return $service; - } - public function testgetCourse() - + public function testgetCourse() { - $service = $this->getService(); - $classroomResponse = getCourse($service, '531365794650'); + $classroomResponse = getCourse('123456'); $this->assertNotNull($classroomResponse, "Not get any value from service"); } diff --git a/classroom/snippets/test/ClassroomListAllCoursesTest.php b/classroom/snippets/test/ClassroomListAllCoursesTest.php index e2e3752..9da9481 100644 --- a/classroom/snippets/test/ClassroomListAllCoursesTest.php +++ b/classroom/snippets/test/ClassroomListAllCoursesTest.php @@ -20,23 +20,11 @@ class ClassroomListAllCoursesTest extends \PHPUnit\Framework\TestCase { - protected function getService() - { - $client = new Google\Client(); - $client->useApplicationDefaultCredentials(); - $client->addScope("https://www.googleapis.com/auth/classroom.courses"); - $service = new Google_Service_Classroom($client); - return $service; - } - public function testlistAllCourses() - + public function testlistAllCourses() { - - $service = $this->getService(); - $classroomResponse = listCourses($service); + $classroomResponse = listCourses(); $this->assertNotNull($classroomResponse, "Not get any value from service"); - } diff --git a/classroom/snippets/test/ClassroomPatchCourseTest.php b/classroom/snippets/test/ClassroomPatchCourseTest.php index 7a7887d..0a03cb9 100644 --- a/classroom/snippets/test/ClassroomPatchCourseTest.php +++ b/classroom/snippets/test/ClassroomPatchCourseTest.php @@ -20,25 +20,10 @@ class ClassroomPatchCourseTest extends \PHPUnit\Framework\TestCase { - protected function getService() + public function testlistAllCourses() { - $client = new Google\Client(); - $client->useApplicationDefaultCredentials(); - $client->addScope("https://www.googleapis.com/auth/classroom.courses"); - $service = new Google_Service_Classroom($client); - return $service; - } - - public function testlistAllCourses() - - { - - $service = $this->getService(); - $classroomResponse = patchCourse($service); + $classroomResponse = patchCourse('531365683519'); $this->assertNotNull($classroomResponse, "Not get any value from service"); - } - - } diff --git a/classroom/snippets/test/ClassroomUpdateCourseTest.php b/classroom/snippets/test/ClassroomUpdateCourseTest.php index a1ff993..c64542f 100644 --- a/classroom/snippets/test/ClassroomUpdateCourseTest.php +++ b/classroom/snippets/test/ClassroomUpdateCourseTest.php @@ -20,21 +20,12 @@ class ClassroomUpdateCourseTest extends \PHPUnit\Framework\TestCase { - protected function getService() - { - $client = new Google\Client(); - $client->useApplicationDefaultCredentials(); - $client->addScope("https://www.googleapis.com/auth/classroom.courses"); - $service = new Google_Service_Classroom($client); - return $service; - } + public function testcreateCourseAlias() - { - - $service = $this->getService(); - $classroomResponse = updateCourse($service); + { + $classroomResponse = updateCourse( '531365794650'); $this->assertNotNull($classroomResponse, "Not get any value from service"); }