entries as $entry) { $bo->delete($entry); } parent::tearDown(); } public function testSimpleReadWrite(): string { $info_id = $this->make_infolog(); $this->files[] = $this->test_file = $this->getFilename(null, $info_id); return parent::testSimpleReadWrite(); } public function testNoReadAccess(): void { $info_id = $this->make_infolog(); $this->files[] = $this->test_file = $this->getFilename(null, $info_id); parent::testNoReadAccess(); } public function testWithAccess(): void { $info_id = $this->make_infolog(); $this->files[] = $this->test_file = $this->getFilename(null, $info_id); parent::testWithAccess(); } protected function allowAccess(string $test_name, string &$test_file, int $test_user, string $needed) : void { // We'll allow access by putting test user in responsible $so = new \infolog_so(); $element = $so->read(Array('info_id' => $this->entries[0])); $element['info_responsible'] = [$test_user]; $so->write($element); } protected function mount() : void { $this->mountLinks('/apps'); } /** * Make an infolog entry */ protected function make_infolog() { $bo = new \infolog_bo(); $element = array( 'info_subject' => "Test infolog for #{$this->getName()}", 'info_des' => 'Test element for ' . $this->getName() . "\n" . Api\DateTime::to(), 'info_status' => 'open' ); $element_id = $bo->write($element, true, true, true, true); $this->entries[] = $element_id; return $element_id; } /** * Make a filename that reflects the current test * @param $path * @param $info_id * @return string * @throws \ReflectionException */ protected function getFilename($path, $info_id) { if(is_null($path)) $path = '/apps/infolog/'; if(substr($path,-1,1) !== '/') $path = $path . '/'; $reflect = new \ReflectionClass($this); return $path .$info_id .'/'. $reflect->getShortName() . '_' . $this->getName() . '.txt'; } }