container = new Container(); } /** * Test that the container can bind and resolve a simple closure. */ public function test_it_can_bind_and_resolve_closure(): void { $this->container->bind('foo', function () { return 'bar'; }); $this->assertEquals('bar', $this->container->make('foo')); } /** * Test that the container can bind and resolve a singleton. */ public function test_it_can_bind_and_resolve_singleton(): void { $this->container->singleton('std', function () { return new \stdClass(); }); $instance1 = $this->container->make('std'); $instance2 = $this->container->make('std'); $this->assertSame($instance1, $instance2); } /** * Test that the container can resolve a class name directly. */ public function test_it_can_resolve_class_directly(): void { $instance = $this->container->make(\stdClass::class); $this->assertInstanceOf(\stdClass::class, $instance); } }