CRUDlexTests\SimpleFilesystemFileProcessorTest::testUpdateFile PHP Method

testUpdateFile() public method

public testUpdateFile ( )
    public function testUpdateFile()
    {
        $this->cleanUpFiles();
        $entityLibrary = $this->dataLibrary->createEmpty();
        $entityLibrary->set('name', 'lib');
        $this->dataLibrary->create($entityLibrary);
        $entityBook = $this->dataBook->createEmpty();
        $entityBook->set('title', 'title');
        $entityBook->set('author', 'author');
        $entityBook->set('pages', 111);
        $entityBook->set('library', $entityLibrary->get('id'));
        $this->dataBook->create($entityBook);
        $file = __DIR__ . '/../test1A.xml';
        copy(__DIR__ . '/../test1.xml', $file);
        $request = new Request([], ['title' => 'title', 'author' => 'author', 'pages' => 111, 'library' => $entityLibrary->get('id')], [], [], ['cover' => new UploadedFile($file, 'test1A.xml', 'application/xml', filesize($file), null, true)]);
        $this->fileProcessor->createFile($request, $entityBook, 'book', 'cover');
        $file2 = __DIR__ . '/../test2A.xml';
        copy(__DIR__ . '/../test2.xml', $file2);
        $request = new Request([], ['title' => 'title', 'author' => 'author', 'pages' => 111, 'library' => $entityLibrary->get('id')], [], [], ['cover' => new UploadedFile($file2, 'test2A.xml', 'application/xml', filesize($file2), null, true)]);
        $this->fileProcessor->updateFile($request, $entityBook, 'book', 'cover');
        $this->assertTrue(file_exists($this->file1));
        $this->assertTrue(file_exists($this->file2));
    }