This repository was archived by the owner on Jul 17, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ trait UploadTrait
2727 */
2828 public function getFileUpload ()
2929 {
30- $ propertyName = $ this ->getFileUploadPropertyName ();
30+ $ propertyName = $ this ->getFileUploadPropertyName (__FUNCTION__ );
3131
3232 if (isset ($ this ->fileUploads [$ propertyName ])) {
3333 return $ this ->fileUploads [$ propertyName ];
Original file line number Diff line number Diff line change @@ -61,4 +61,40 @@ public function testSetFileUploadFromProxy()
6161 $ uploadEntityProxyMock
6262 );
6363 }
64+
65+ /**
66+ * Tests if the UploadEntityMock::getImageUpload (alias of UploadTrait::getFileUpload)
67+ * returns the expected file uploads property.
68+ */
69+ public function testGetFileUpload ()
70+ {
71+ $ uploadedFileMock = $ this ->getMockBuilder (UploadedFile::class)
72+ ->disableOriginalConstructor ()
73+ ->getMock ();
74+
75+ $ entityMock = new UploadEntityMock ();
76+ $ entityMock ->setImageUpload ($ uploadedFileMock );
77+
78+ $ this ->assertSame ($ uploadedFileMock , $ entityMock ->getImageUpload ($ uploadedFileMock ));
79+ }
80+
81+ /**
82+ * Tests if the UploadEntityProxyMock::getImageUpload (alias of UploadTrait::getFileUpload)
83+ * sets the expected file uploads property.
84+ *
85+ * This tests the scenario of a Doctrine entity being a parent class of
86+ * a proxy class with all the method overloaded as this changes the
87+ * PHP stack to determine the caller method.
88+ */
89+ public function testGetFileUploadFromProxy ()
90+ {
91+ $ uploadedFileMock = $ this ->getMockBuilder (UploadedFile::class)
92+ ->disableOriginalConstructor ()
93+ ->getMock ();
94+
95+ $ uploadEntityProxyMock = new UploadEntityProxyMock ();
96+ $ uploadEntityProxyMock ->setImageUpload ($ uploadedFileMock );
97+
98+ $ this ->assertSame ($ uploadedFileMock , $ uploadEntityProxyMock ->getImageUpload ($ uploadedFileMock ));
99+ }
64100}
Original file line number Diff line number Diff line change 1111 */
1212class UploadEntityProxyMock extends UploadEntityMock
1313{
14+ /**
15+ * Overloaded trait method alias.
16+ *
17+ * @return UploadedFile
18+ */
19+ public function getImageUpload ()
20+ {
21+ return parent ::getImageUpload ();
22+ }
23+
1424 /**
1525 * Overloaded trait method alias.
1626 *
You can’t perform that action at this time.
0 commit comments