File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 5656use InvalidArgumentException ;
5757use LogicException ;
5858use Mockery as m ;
59+ use PHPUnit \Framework \Attributes \TestWith ;
5960use PHPUnit \Framework \TestCase ;
6061use ReflectionClass ;
6162use stdClass ;
@@ -1317,6 +1318,23 @@ public function testConnectionManagement()
13171318 $ this ->assertSame ('bar ' , $ model ->getConnection ());
13181319 }
13191320
1321+ #[TestWith(['Foo ' ])]
1322+ #[TestWith([ConnectionName::Foo])]
1323+ #[TestWith([ConnectionNameBacked::Foo])]
1324+ public function testConnectionEnums (string |\UnitEnum $ connectionName )
1325+ {
1326+ EloquentModelStub::setConnectionResolver ($ resolver = m::mock (ConnectionResolverInterface::class));
1327+ $ model = new EloquentModelStub ;
1328+
1329+ $ retval = $ model ->setConnection ($ connectionName );
1330+ $ this ->assertEquals ($ retval , $ model );
1331+ $ this ->assertSame ('Foo ' , $ model ->getConnectionName ());
1332+
1333+ $ resolver ->shouldReceive ('connection ' )->once ()->with ('Foo ' )->andReturn ('bar ' );
1334+
1335+ $ this ->assertSame ('bar ' , $ model ->getConnection ());
1336+ }
1337+
13201338 public function testToArray ()
13211339 {
13221340 $ model = new EloquentModelStub ;
@@ -4432,3 +4450,13 @@ public function __toString()
44324450 return $ this ->cast ;
44334451 }
44344452}
4453+
4454+ enum ConnectionName {
4455+ case Foo;
4456+ case Bar;
4457+ }
4458+
4459+ enum ConnectionNameBacked : string {
4460+ case Foo = 'Foo ' ;
4461+ case Bar = 'Bar ' ;
4462+ }
You can’t perform that action at this time.
0 commit comments