File tree 2 files changed +15
-13
lines changed 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change 4
4
5
5
class MiscellaneousTest extends \PHPUnit \Framework \TestCase
6
6
{
7
- public function testNoStringPrimaryKey () : void
8
- {
9
- $ customer = new \Tests \App \Record \Customer (1 );
10
- $ this ->assertTrue ($ customer ->loaded ());
11
- $ this ->expectException (\PHPFUI \ORM \Exception::class);
12
- $ customer = new \Tests \App \Record \Customer ('test ' );
13
- }
14
-
15
7
public function testRow () : void
16
8
{
17
9
$ row = \PHPFUI \ORM ::getRow ('select * from customer ' );
Original file line number Diff line number Diff line change @@ -63,18 +63,28 @@ public function __construct(int|array|null|string $parameter = null)
63
63
64
64
switch ($ type )
65
65
{
66
- case 'integer ' :
67
- $ type = 'int ' ;
68
- // Intentionally fall through
69
66
case 'string ' :
70
67
71
- if (1 == \count (static ::$ primaryKeys ) && $ type == static ::$ fields [static ::$ primaryKeys [0 ]][self ::PHP_TYPE_INDEX ])
68
+ if (1 == \count (static ::$ primaryKeys ))
69
+ {
70
+ $ this ->read ($ parameter );
71
+ }
72
+ else
73
+ {
74
+ throw new \PHPFUI \ORM \Exception (static ::class . ' has no string primary key ' );
75
+ }
76
+
77
+ break ;
78
+
79
+ case 'integer ' :
80
+
81
+ if (1 == \count (static ::$ primaryKeys ) && 'int ' == static ::$ fields [static ::$ primaryKeys [0 ]][self ::PHP_TYPE_INDEX ])
72
82
{
73
83
$ this ->read ($ parameter );
74
84
}
75
85
else
76
86
{
77
- throw new \PHPFUI \ORM \Exception (static ::class . ' has no ' . $ type . ' primary key ' );
87
+ throw new \PHPFUI \ORM \Exception (static ::class . ' does not have an integer primary key ' );
78
88
}
79
89
80
90
break ;
You can’t perform that action at this time.
0 commit comments