Пример #1
0
 public function testLevelValidation()
 {
     $this->userMock->shouldIgnoreMissing();
     $this->action('GET', $this->controller . '@index', [], ['level' => 'invalid']);
     $this->assertResponseStatus(HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
     $this->action('GET', $this->controller . '@index', [], ['level' => 1]);
     $this->assertResponseOk();
 }
 public function setUp()
 {
     parent::setUp();
     $this->carbon = m::mock('Carbon\\Carbon');
     $this->carbon->shouldIgnoreMissing();
     $this->cronExpression = m::mock('Cron\\CronExpression');
     $this->app->instance('Cron\\CronExpression', $this->cronExpression);
     $this->scheduler = m::mock('Indatus\\Dispatcher\\Drivers\\DateTime\\Scheduler');
     $this->scheduler->shouldIgnoreMissing();
     $this->interpreter = m::mock('Indatus\\Dispatcher\\Drivers\\DateTime\\ScheduleInterpreter[]', [$this->scheduler, $this->carbon]);
 }
Пример #3
0
 /**
  * @throws \InvalidArgumentException
  *
  * @return MockInterface
  */
 private function mockStripeCharge() : MockInterface
 {
     if ($this->mockStripeCharge === null) {
         $this->mockStripeCharge = Mockery::mock(Charge::class);
         $this->mockStripeCharge->shouldIgnoreMissing()->asUndefined();
         app()->extend(Charge::class, function () {
             return $this->mockStripeCharge;
         });
     }
     return $this->mockStripeCharge;
 }
Пример #4
0
 /**
  * @throws \InvalidArgumentException
  *
  * @return Payment|MockInterface
  */
 private function mockPayPalPayment()
 {
     if ($this->payPalPayment === null) {
         $this->payPalPayment = Mockery::mock(Payment::class);
         $this->payPalPayment->shouldIgnoreMissing()->asUndefined();
         app()->extend(Payment::class, function () {
             return $this->payPalPayment;
         });
     }
     return $this->payPalPayment;
 }
 public function testNextCallableIsInvoked()
 {
     $this->logger->shouldIgnoreMissing();
     $this->formatter->shouldIgnoreMissing();
     $sentCommand = new RegisterUserCommand();
     $receivedSameCommand = false;
     $next = function ($receivedCommand) use(&$receivedSameCommand, $sentCommand) {
         $receivedSameCommand = $receivedCommand === $sentCommand;
     };
     $this->middleware->execute($sentCommand, $next);
     $this->assertTrue($receivedSameCommand);
 }
Пример #6
0
 public function setUp()
 {
     parent::setUp();
     $this->scheduler = App::make('Indatus\\Dispatcher\\Drivers\\DateTime\\Scheduler');
     $this->interpreter = m::mock('Indatus\\Dispatcher\\Drivers\\DateTime\\ScheduleInterpreter');
     $this->interpreter->shouldIgnoreMissing(false);
     $this->app->instance('Indatus\\Dispatcher\\Drivers\\DateTime\\ScheduleInterpreter', $this->interpreter);
     $this->logger = m::mock('Illuminate\\Contracts\\Logging\\Log');
     $this->app->instance('Illuminate\\Contracts\\Logging\\Log', $this->logger);
     $this->console = m::mock('Illuminate\\Contracts\\Console\\Kernel');
     $this->scheduleService = new ScheduleService($this->console);
 }
Пример #7
0
 public function setUp()
 {
     $this->logger = m::mock('\\Monolog\\Logger');
     $this->logger->shouldIgnoreMissing();
     $this->manager = m::mock('\\Spork\\ProcessManager');
     $this->manager->shouldReceive('wait')->atLeast(1);
     $this->events = m::mock('\\Symfony\\Component\\EventDispatcher\\EventDispatcher');
     //$this->events->shouldReceive('dispatch')->zeroOrMoreTimes();
     $this->pcntl = test::double('Beelzebub\\Wrapper\\Pcntl', array('signal' => true));
     $this->posix = $this->getPosixDouble();
     $this->builtin = test::double('Beelzebub\\Wrapper\\Builtin', array('doExit' => null, 'doUsleep' => null));
     parent::setUp();
 }
Пример #8
0
 public function testAddFollowerValidation()
 {
     $this->userMock->shouldIgnoreMissing();
     $this->action('POST', $this->controller . '@store');
     $this->assertResponseStatus(HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
     $this->action('POST', $this->controller . '@store', ['userId' => 'invalid']);
     $this->assertResponseStatus(HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
     $this->followingMock->shouldReceive('loadUsers')->once()->andReturn(false);
     $this->action('POST', $this->controller . '@store', ['userId' => -1]);
     $this->assertResponseStatus(HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
     $this->followingMock->shouldReceive('loadUsers')->once()->andReturn(true)->shouldReceive('isLinked')->once()->andReturn(true);
     $this->action('POST', $this->controller . '@store', ['userId' => 0]);
     $this->assertResponseStatus(HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
 }
Пример #9
0
 private function setUpTestRun($case)
 {
     // Matcher
     $this->router->shouldReceive('match')->once()->withAnyArgs()->andReturn($case['route']);
     // Request
     $this->request->shouldIgnoreMissing();
     $this->request->server = $this->getBag('ServerBag');
     $this->request->server->shouldIgnoreMissing([]);
     $this->presenter->shouldReceive('getAvailableFormats')->once()->withNoArgs()->andReturn($case['formats']);
     $this->action_factory->shouldReceive('newInstance')->once()->withAnyArgs()->andReturn($case['action']);
     $this->event_dispatcher->shouldReceive('dispatch')->once()->with(DispatchEvents::PRE_DISPATCH, \Mockery::any())->andReturnNull();
     $this->event_dispatcher->shouldReceive('dispatch')->with(DispatchEvents::POST_DISPATCH, \Mockery::any())->andReturnNull();
     $this->event_dispatcher->shouldReceive('dispatch')->with(DispatchEvents::PRE_PRESENT, \Mockery::any())->andReturnNull();
     $this->event_dispatcher->shouldReceive('dispatch')->with(DispatchEvents::POST_PRESENT, \Mockery::any())->andReturnNull();
 }
Пример #10
0
 /**
  * @expectedException Modus\Common\Route\Exception\NotFoundException
  */
 public function testNotFoundNoErrorPageThrowsException()
 {
     $this->router->shouldReceive('determineRouting')->once()->andReturn(false);
     $this->router->shouldIgnoreMissing();
     $this->config->shouldReceive('getConfig')->andReturn([]);
     $this->bootstrap->execute();
 }
Пример #11
0
 /**
  * @expectedException \Giftcards\FixedWidth\FieldRequiredException
  */
 public function testAddRecordWhereRequiredFieldIsMissing()
 {
     $this->formatter->shouldIgnoreMissing();
     $this->builder->addRecord('record1', array('field1' => 3));
 }
Пример #12
0
 public function testRolloverInSameYearKeepsRelationships()
 {
     $course = $this->createTestCourseWithAssociations();
     $newCourse = m::mock('Ilios\\CoreBundle\\Entity\\CourseInterface');
     $newYear = $course->getYear();
     $newTitle = $course->getTitle() . ' again';
     $this->courseManager->shouldReceive('findOneBy')->withArgs([['id' => $course->getId()]])->andReturn($course)->once();
     $this->courseManager->shouldReceive('findBy')->withArgs([['title' => $newTitle, 'year' => $newYear]])->andReturn(false)->once();
     $this->courseManager->shouldReceive('update')->withArgs([$newCourse, false, false])->once();
     $this->courseManager->shouldReceive('create')->once()->andReturn($newCourse);
     $this->courseManager->shouldReceive('flushAndClear')->once();
     $newCourse->shouldReceive()->setCohorts()->with($course->getCohorts());
     $newCourse->shouldIgnoreMissing();
     foreach ($course->getObjectives() as $objective) {
         $newObjective = m::mock('Ilios\\CoreBundle\\Entity\\Objective');
         $newObjective->shouldReceive('setTitle')->with($objective->getTitle())->once();
         $newObjective->shouldReceive('addCourse')->with($newCourse)->once();
         $newObjective->shouldReceive('setMeshDescriptors')->with($objective->getMeshDescriptors())->once();
         $newObjective->shouldReceive('setParents')->with($objective->getParents());
         $this->objectiveManager->shouldReceive('create')->once()->andReturn($newObjective);
         $this->objectiveManager->shouldReceive('update')->once()->withArgs([$newObjective, false, false]);
     }
     foreach ($course->getLearningMaterials() as $learningMaterial) {
         $newLearningMaterial = m::mock('Ilios\\CoreBundle\\Entity\\CourseLearningMaterial');
         $newLearningMaterial->shouldIgnoreMissing();
         $this->courseLearningMaterialManager->shouldReceive('create')->once()->andReturn($newLearningMaterial);
         $this->courseLearningMaterialManager->shouldIgnoreMissing();
     }
     foreach ($course->getSessions() as $session) {
         $newSession = m::mock('Ilios\\CoreBundle\\Entity\\Session');
         $newSession->shouldIgnoreMissing();
         $this->sessionManager->shouldReceive('create')->once()->andReturn($newSession);
         $this->sessionManager->shouldReceive('update')->withArgs([$newSession, false, false])->once();
         foreach ($session->getObjectives() as $objective) {
             $newObjective = m::mock('Ilios\\CoreBundle\\Entity\\Objective');
             $newObjective->shouldIgnoreMissing();
             $this->objectiveManager->shouldReceive('create')->once()->andReturn($newObjective);
             $this->objectiveManager->shouldIgnoreMissing();
         }
         foreach ($session->getLearningMaterials() as $learningMaterial) {
             $newLearningMaterial = m::mock('Ilios\\CoreBundle\\Entity\\SessionLearningMaterial');
             $newLearningMaterial->shouldIgnoreMissing();
             $this->sessionLearningMaterialManager->shouldReceive('create')->once()->andReturn($newLearningMaterial);
             $this->sessionLearningMaterialManager->shouldIgnoreMissing();
         }
         if ($oldDescription = $session->getSessionDescription()) {
             $newDescription = m::mock('Ilios\\CoreBundle\\Entity\\SessionDescriptionInterface');
             $newDescription->shouldReceive('setDescription')->with($oldDescription->getDescription())->once();
             $newSession->shouldReceive('setSessionDescription')->with($newDescription)->once();
             $this->sessionDescriptionManager->shouldReceive('create')->once()->andReturn($newDescription);
             $this->sessionDescriptionManager->shouldReceive('update')->once()->withArgs([$newDescription, false, false]);
         }
         if ($oldIlmSession = $session->getIlmSession()) {
             $newIlmSession = m::mock('Ilios\\CoreBundle\\Entity\\IlmSessionInterface');
             $newIlmSession->shouldReceive('setHours')->with($oldIlmSession->getHours())->once();
             $newIlmSession->shouldReceive('setDueDate')->with(m::on(function (DateTime $newDueDate) use($oldIlmSession) {
                 $oldDueDate = $oldIlmSession->getDueDate();
                 return $oldDueDate->format('w') === $newDueDate->format('w') && $oldDueDate->format('W') === $newDueDate->format('W');
             }))->once();
             $newSession->shouldReceive('setIlmSession')->with($newIlmSession)->once();
             $this->ilmSessionManager->shouldReceive('create')->once()->andReturn($newIlmSession);
             $this->ilmSessionManager->shouldReceive('update')->once()->withArgs([$newIlmSession, false, false]);
         }
         foreach ($session->getOfferings() as $offering) {
             $newOffering = m::mock('Ilios\\CoreBundle\\Entity\\Offering');
             $newOffering->shouldReceive('setRoom')->once()->with($offering->getRoom());
             $newOffering->shouldReceive('setSite')->once()->with($offering->getSite());
             $newOffering->shouldReceive('setStartDate')->with(m::on(function (DateTime $newStart) use($offering) {
                 $oldStart = $offering->getStartDate();
                 return $oldStart->format('w') === $newStart->format('w') && $oldStart->format('W') === $newStart->format('W');
             }))->once();
             $newOffering->shouldReceive('setEndDate')->with(m::on(function (DateTime $newEnd) use($offering) {
                 $oldEnd = $offering->getEndDate();
                 return $oldEnd->format('w') === $newEnd->format('w') && $oldEnd->format('W') === $newEnd->format('W');
             }))->once();
             $newOffering->shouldReceive('setSession')->once()->with($newSession);
             $newOffering->shouldReceive('setInstructors')->once()->with($offering->getInstructors());
             $newOffering->shouldReceive('setInstructorGroups')->once()->with($offering->getInstructorGroups());
             $newOffering->shouldNotReceive('setLearnerGroups');
             $newOffering->shouldNotReceive('setLearners');
             $this->offeringManager->shouldReceive('create')->once()->andReturn($newOffering);
             $this->offeringManager->shouldReceive('update')->once()->withArgs([$newOffering, false, false]);
         }
     }
     $this->objectiveManager->shouldIgnoreMissing();
     $rhett = $this->service->rolloverCourse($course->getId(), $newYear, ['new-course-title' => $newTitle]);
     $this->assertSame($newCourse, $rhett);
 }