config = $this->prophesize(Config::class); } public function testThrowsExceptionOnMissingConfig() { $this->config->get('cameraImageBaseFolder', Argument::any())->willReturn(false); $cameraPictureManager = new CameraPictureManagerService($this->config->reveal()); $this->expectException(\InvalidArgumentException::class); $cameraPictureManager->getLatestCameraPictures(); } public function testThrowsExceptionOnBadConfig() { $this->config->get('cameraImageBaseFolder', Argument::any())->willReturn("--sadf"); $cameraPictureManager = new CameraPictureManagerService($this->config->reveal()); $this->expectException(\InvalidArgumentException::class); $cameraPictureManager->getLatestCameraPictures(); } public function testReturnsImages() { $this->config->get('cameraImageBaseFolder', Argument::any())->willReturn(self::TEST_DATA_DIR); $cameraPictureManager = new CameraPictureManagerService($this->config->reveal()); $result = $cameraPictureManager->getLatestCameraPictures(); $this->assertCount(3, $result); } public function testThrowsExceptionOnBadImage() { $this->config->get('cameraImageBaseFolder', Argument::any())->willReturn(self::TEST_DATA_DIR); $cameraPictureManager = new CameraPictureManagerService($this->config->reveal()); $this->expectException(\InvalidArgumentException::class); $cameraPictureManager->getCameraImage(self::EXISTING_CAM_DIR, self::MISSING_IMAGE); } public function testReturnsResponseOnExistingImage() { $this->config->get('cameraImageBaseFolder', Argument::any())->willReturn(self::TEST_DATA_DIR); $cameraPictureManager = new CameraPictureManagerService($this->config->reveal()); $result = $cameraPictureManager->getCameraImage(self::EXISTING_CAM_DIR, self::EXISTING_IMAGE); $this->assertInstanceOf(Response::class, $result); } }