File tree 8 files changed +83
-4
lines changed
8 files changed +83
-4
lines changed Original file line number Diff line number Diff line change 27
27
"autoload" : {
28
28
"psr-4" : {
29
29
"Faker\\ " : " src/Faker/"
30
- },
31
- "files" : [
32
- " src/Faker/ORM/Doctrine/backward-compatibility.php"
33
- ]
30
+ }
34
31
},
35
32
"autoload-dev" : {
36
33
"psr-4" : {
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ includes:
3
3
4
4
parameters:
5
5
level: 5
6
+ bootstrapFiles:
7
+ - src/Faker/ORM/Doctrine/backward-compatibility.php
6
8
paths:
7
9
- src
8
10
tmpDir: .build/phpstan/
Original file line number Diff line number Diff line change 5
5
use Doctrine \Common \Persistence \Mapping \ClassMetadata ;
6
6
use Faker \Generator ;
7
7
8
+ require_once 'backward-compatibility.php ' ;
9
+
8
10
class ColumnTypeGuesser
9
11
{
10
12
protected $ generator ;
Original file line number Diff line number Diff line change 5
5
use Doctrine \Common \Persistence \Mapping \ClassMetadata ;
6
6
use Doctrine \Common \Persistence \ObjectManager ;
7
7
8
+ require_once 'backward-compatibility.php ' ;
9
+
8
10
/**
9
11
* Service class for populating a table through a Doctrine Entity class.
10
12
*/
Original file line number Diff line number Diff line change 5
5
use Doctrine \Common \Persistence \ObjectManager ;
6
6
use Faker \Generator ;
7
7
8
+ require_once 'backward-compatibility.php ' ;
9
+
8
10
/**
9
11
* Service class for populating a database using the Doctrine ORM or ODM.
10
12
* A Populator can populate several tables using ActiveRecord classes.
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Faker \Test \ORM \Doctrine ;
6
+
7
+ use Faker \ORM \Doctrine \ColumnTypeGuesser ;
8
+ use Faker \Test \TestCase ;
9
+
10
+ final class ColumnTypeGuesserTest extends TestCase
11
+ {
12
+ /**
13
+ * @runInSeparateProcess
14
+ */
15
+ public function testClassGenerationWithBackwardCompatibility (): void
16
+ {
17
+ $ columnTypeGuesser = new ColumnTypeGuesser ($ this ->faker );
18
+ // Mock ClassMetadata after autoload to test class alias
19
+ $ classMetaData = $ this ->createMock ('Doctrine\Common\Persistence\Mapping\ClassMetadata ' );
20
+ $ classMetaData ->method ('getTypeOfField ' )->with (self ::anything ())->willReturn ('integer ' );
21
+
22
+ $ fakerClosure = $ columnTypeGuesser ->guessFormat ('test ' , $ classMetaData );
23
+ self ::assertIsNumeric ($ fakerClosure ());
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Faker \Test \ORM \Doctrine ;
6
+
7
+ use Faker \ORM \Doctrine \EntityPopulator ;
8
+ use Faker \Test \TestCase ;
9
+
10
+ final class EntityPopulatorTest extends TestCase
11
+ {
12
+ /**
13
+ * @runInSeparateProcess
14
+ */
15
+ public function testClassGenerationWithBackwardCompatibility (): void
16
+ {
17
+ // trigger autoload before using to load backward compatibility fix
18
+ class_exists (EntityPopulator::class);
19
+
20
+ $ classMetaData = $ this ->createMock ('Doctrine\Common\Persistence\Mapping\ClassMetadata ' );
21
+ $ classMetaData ->method ('getName ' )->willReturn ('test ' );
22
+ $ entityPopulator = new EntityPopulator ($ classMetaData );
23
+
24
+ self ::assertSame ('test ' , $ entityPopulator ->getClass ());
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Faker \Test \ORM \Doctrine ;
6
+
7
+ use Faker \ORM \Doctrine \Populator ;
8
+ use Faker \Test \TestCase ;
9
+
10
+ final class PopulatorTest extends TestCase
11
+ {
12
+ /**
13
+ * @runInSeparateProcess
14
+ */
15
+ public function testClassGenerationWithBackwardCompatibility (): void
16
+ {
17
+ $ populator = new Populator ($ this ->faker );
18
+ // Mock ObjectManager after autoload to test class alias
19
+ $ objectManager = $ this ->createMock ('Doctrine\Common\Persistence\ObjectManager ' );
20
+
21
+ self ::assertEmpty ($ populator ->execute ($ objectManager ));
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments