Пример #1
0
 public function testValidateFail()
 {
     $menu = new AuthenticatedMenu();
     $menu->setContainer($this->container);
     $this->container->shouldReceive('get')->once()->withArgs(['security.authorization_checker'])->andReturn($this->security);
     $this->security->shouldReceive('isGranted')->once()->withArgs(['IS_AUTHENTICATED_REMEMBERED'])->andReturn(false);
     $this->assertFalse($menu->validate());
     $this->security->shouldHaveReceived('isGranted')->once()->withArgs(['IS_AUTHENTICATED_REMEMBERED']);
 }
Пример #2
0
 /**
  * @covers \Ilios\CliBundle\Command\AddRootUserCommand::execute
  */
 public function testAddRootUser()
 {
     $userId = 1;
     $user = m::mock('Ilios\\CoreBundle\\Entity\\User');
     $this->userManager->shouldReceive('findOneBy')->with(['id' => $userId])->andReturn($user);
     $this->userManager->shouldReceive('update');
     $user->shouldReceive('setRoot');
     $this->commandTester->execute(['command' => AddRootUserCommand::COMMAND_NAME, 'userId' => $userId]);
     $this->userManager->shouldHaveReceived('update', [$user, true, true]);
     $user->shouldHaveReceived('setRoot', [true]);
     $output = $this->commandTester->getDisplay();
     $this->assertEquals("User with id #{$userId} has been granted root-level privileges.", trim($output));
 }
 public function testCommandPrintsOutNewCourseIdOnSuccess()
 {
     $courseId = '1';
     $newAcademicYear = '2017';
     $newCourseId = 5;
     $this->service->shouldReceive('rolloverCourse')->andReturnUsing(function () use($newCourseId) {
         $course = new Course();
         $course->setId($newCourseId);
         return $course;
     });
     $this->commandTester->execute(['command' => self::COMMAND_NAME, 'courseId' => $courseId, 'newAcademicYear' => $newAcademicYear]);
     $this->service->shouldHaveReceived('rolloverCourse')->withAnyArgs()->once();
     $output = $this->commandTester->getDisplay();
     $this->assertEquals("This course has been rolled over. The new course id is {$newCourseId}.", trim($output));
 }
 /**
  * @covers \Ilios\CoreBundle\EventListener\TrackApiUsageListener::onKernelController
  */
 public function testTrackingFailure()
 {
     $uri = '/api/v1/foo/bar/baz';
     $host = 'iliosproject.org';
     $e = new \Exception();
     $this->mockRequest->shouldReceive('getRequestUri')->andReturn($uri);
     $this->mockRequest->shouldReceive('getHost')->andReturn($host);
     $this->mockTracker->shouldReceive('send')->andReturnUsing(function () use($e) {
         throw $e;
     });
     $listener = new TrackApiUsageListener(true, $this->mockTracker, $this->mockLogger);
     $listener->onKernelController($this->mockEvent);
     $this->mockLogger->shouldHaveReceived('error')->withArgs(['Failed to send tracking data.', ['exception' => $e]]);
     unset($mockLogger);
 }
 public function testCommandPrintsOutNewReportIdOnSuccess()
 {
     $reportId = '1';
     $newReportId = 5;
     $this->service->shouldReceive('rollover')->andReturnUsing(function () use($newReportId) {
         $report = new CurriculumInventoryReport();
         $report->setId($newReportId);
         return $report;
     });
     $this->reportManager->shouldReceive('findOneBy')->with(['id' => $reportId])->andReturnUsing(function () use($reportId) {
         $report = new CurriculumInventoryReport();
         $report->setId($reportId);
         return $report;
     });
     $this->commandTester->execute(['command' => self::COMMAND_NAME, 'reportId' => $reportId]);
     $this->service->shouldHaveReceived('rollover')->withAnyArgs()->once();
     $output = $this->commandTester->getDisplay();
     $this->assertEquals("The given report has been rolled over. The new report id is {$newReportId}.", trim($output));
 }
Пример #6
0
 /**
  * @return @test
  */
 public function canBeInitialized()
 {
     $this->body->shouldReceive('__toString')->andReturn('');
     $this->assertEmpty($this->response->getContent());
     $this->body->shouldHaveReceived('__toString')->withNoArgs();
 }
Пример #7
0
 public function testKernelGetsBooted()
 {
     new Application($this->kernel);
     $this->kernel->shouldHaveReceived('boot')->once();
 }