CRUDlexTests\EntityTest::testPopulateViaRequest PHP Method

testPopulateViaRequest() public method

    public function testPopulateViaRequest()
    {
        $book = $this->dataBook->createEmpty();
        $file = __DIR__ . '/../test1.xml';
        $request = Request::create('', 'POST', ['title' => 'a title'], [], ['cover' => new UploadedFile($file, 'test1.xml', 'application/xml', filesize($file), null, true)]);
        $book->populateViaRequest($request);
        $read = $book->get('title');
        $expected = 'a title';
        $this->assertSame($expected, $read);
        $read = $book->get('cover');
        $expected = 'test1.xml';
        $this->assertSame($expected, $read);
        $library = $this->dataLibrary->createEmpty();
        $request = Request::create('', 'POST', ['libraryBook' => ['3']], [], []);
        $library->populateViaRequest($request);
        $read = $library->get('libraryBook');
        $expected = [['id' => '3']];
        $this->assertSame($expected, $read);
    }