CRUDlexTests\SimpleFilesystemFileProcessorTest::testRenderFile PHP Method

testRenderFile() public method

public testRenderFile ( )
    public function testRenderFile()
    {
        $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'));
        $entityBook->set('cover', 'test1A.xml');
        $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');
        ob_start();
        $this->fileProcessor->renderFile($entityBook, 'book', 'cover');
        $read = ob_get_clean();
        $read = str_replace("\r", '', $read);
        // For testing under Windows.
        $expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
        $expected .= "<test>test1</test>\n";
        $this->assertSame($read, $expected);
    }