diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 13566b8..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/Php-Template.iml b/.idea/Php-Template.iml
deleted file mode 100644
index ace71b3..0000000
--- a/.idea/Php-Template.iml
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/codeception.xml b/.idea/codeception.xml
deleted file mode 100644
index 330f2dd..0000000
--- a/.idea/codeception.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copilot.data.migration.agent.xml b/.idea/copilot.data.migration.agent.xml
deleted file mode 100644
index 4ea72a9..0000000
--- a/.idea/copilot.data.migration.agent.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copilot.data.migration.ask.xml b/.idea/copilot.data.migration.ask.xml
deleted file mode 100644
index 7ef04e2..0000000
--- a/.idea/copilot.data.migration.ask.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copilot.data.migration.ask2agent.xml b/.idea/copilot.data.migration.ask2agent.xml
deleted file mode 100644
index 1f2ea11..0000000
--- a/.idea/copilot.data.migration.ask2agent.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copilot.data.migration.edit.xml b/.idea/copilot.data.migration.edit.xml
deleted file mode 100644
index 8648f94..0000000
--- a/.idea/copilot.data.migration.edit.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index d502796..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 469f660..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/php-test-framework.xml b/.idea/php-test-framework.xml
deleted file mode 100644
index fdad0d5..0000000
--- a/.idea/php-test-framework.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/php.xml b/.idea/php.xml
deleted file mode 100644
index 7b36a14..0000000
--- a/.idea/php.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/phpspec.xml b/.idea/phpspec.xml
deleted file mode 100644
index 33107fd..0000000
--- a/.idea/phpspec.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml
deleted file mode 100644
index 4f8104c..0000000
--- a/.idea/phpunit.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 1aefb10..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,236 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $PROJECT_DIR$/composer.json
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- "associatedIndex": 8
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1760539332536
-
-
- 1760539332536
-
-
-
-
-
- 1760541069407
-
-
-
- 1760541069407
-
-
-
- 1760541108168
-
-
-
- 1760541108168
-
-
-
- 1760542147464
-
-
-
- 1760542147464
-
-
-
- 1760542608780
-
-
-
- 1760542608780
-
-
-
- 1760543589486
-
-
-
- 1760543589486
-
-
-
- 1760543798409
-
-
-
- 1760543798409
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 734856b..c60c60e 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ You can access the api at `http://localhost:9501/`
xdebug needs to be built into the container before it will work
```shell
- docker exec -it template-runtime-1 bin/xdebug.sh
+ docker exec -it php-template-composer-runtime-1 bin/xdebug.sh
```
### Install the dependencies
diff --git a/src/Controllers/Controller.php b/src/Controllers/Controller.php
index 641f6d8..e603520 100644
--- a/src/Controllers/Controller.php
+++ b/src/Controllers/Controller.php
@@ -28,6 +28,14 @@ abstract class Controller implements ControllerInterface
throw new NotFoundException("not found");
}
+ /**
+ * @throws NotFoundException
+ */
+ public function put(ServerRequest $request): ResponseInterface
+ {
+ throw new NotFoundException("not found");
+ }
+
/**
* @throws NotFoundException
*/
diff --git a/src/Controllers/ControllerInterface.php b/src/Controllers/ControllerInterface.php
index 68811fe..e3df828 100644
--- a/src/Controllers/ControllerInterface.php
+++ b/src/Controllers/ControllerInterface.php
@@ -25,6 +25,14 @@ interface ControllerInterface
*/
public function post(ServerRequest $request): ResponseInterface;
+ /**
+ * Handle the request and return a response.
+ *
+ * @param ServerRequest $request The request data.
+ * @return ResponseInterface The response data.
+ */
+ public function put(ServerRequest $request): ResponseInterface;
+
/**
* Handle the request and return a response.
*
diff --git a/src/Services/Facade.php b/src/Services/Facade.php
index 355259a..7e8140f 100644
--- a/src/Services/Facade.php
+++ b/src/Services/Facade.php
@@ -278,10 +278,10 @@ class Facade
/**
* Set the application instance.
*
- * @param Container $container
+ * @param Container | null $container
* @return void
*/
- public static function setFacadeContainer(Container $container): void
+ public static function setFacadeContainer(Container | null $container): void
{
static::$container = $container;
}
diff --git a/tests/Controllers/AbstractController.php b/tests/Controllers/AbstractController.php
new file mode 100644
index 0000000..084c4c4
--- /dev/null
+++ b/tests/Controllers/AbstractController.php
@@ -0,0 +1,16 @@
+expectException(\League\Route\Http\Exception\NotFoundException::class);
+ $testClass->get($this->getMockRequest());
+ }
+
+ public function testNotFoundExceptionPost()
+ {
+ $testClass = new TestClass();
+
+ $this->expectException(\League\Route\Http\Exception\NotFoundException::class);
+ $testClass->post($this->getMockRequest());
+ }
+
+ public function testNotFoundExceptionPut()
+ {
+ $testClass = new TestClass();
+
+ $this->expectException(\League\Route\Http\Exception\NotFoundException::class);
+ $testClass->put($this->getMockRequest());
+ }
+
+ public function testNotFoundExceptionDelete()
+ {
+ $testClass = new TestClass();
+
+ $this->expectException(\League\Route\Http\Exception\NotFoundException::class);
+ $testClass->delete($this->getMockRequest());
+ }
+
+ public function testNotFoundExceptionPatch()
+ {
+ $testClass = new TestClass();
+
+ $this->expectException(\League\Route\Http\Exception\NotFoundException::class);
+ $testClass->patch($this->getMockRequest());
+ }
+}
+
+// @ignore
+class TestClass extends Controller
+{
+
+}
diff --git a/tests/Controllers/IndexControllerTest.php b/tests/Controllers/IndexControllerTest.php
new file mode 100644
index 0000000..ff28901
--- /dev/null
+++ b/tests/Controllers/IndexControllerTest.php
@@ -0,0 +1,25 @@
+assertTrue(true);
+
+ $controller = new IndexController();
+
+ $response = $controller->get($this->getMockRequest());
+
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('{"status_code":200,"message":"Server is running"}', (string)$response->getBody());
+ }
+}
diff --git a/tests/Facades/AbstractFacade.php b/tests/Facades/AbstractFacade.php
new file mode 100644
index 0000000..32f2294
--- /dev/null
+++ b/tests/Facades/AbstractFacade.php
@@ -0,0 +1,32 @@
+getFacadeClass();
+
+ $this->assertTrue(
+ method_exists($class, 'getFacadeAccessor'),
+ sprintf('The class %s must implement the method getFacadeAccessor.', $class)
+ );
+
+ $facade = $class::getFacadeRoot();
+
+ $this->assertNotNull(
+ $facade,
+ sprintf('The facade %s is not properly initialized.', $this->getConcrete())
+ );
+ }
+}
\ No newline at end of file
diff --git a/tests/Facades/RedisTest.php b/tests/Facades/RedisTest.php
new file mode 100644
index 0000000..f087c20
--- /dev/null
+++ b/tests/Facades/RedisTest.php
@@ -0,0 +1,21 @@
+getProviderClass();
+
+ /** @var ServiceProvider $providerClass */
+ $provider = new $providerClass($container);
+
+ $this->assertInstanceOf($providerClass, $provider);
+ $provider->register();
+
+ $bindings = $provider->bindings;
+ foreach ($bindings as $abstract => $concrete) {
+ $this->assertTrue($container->bound($abstract), "The $abstract is not bound in the container.");
+ $this->assertNotNull($container->make($abstract), "The $abstract could not be resolved.");
+
+ $this->assertInstanceOf(
+ $concrete,
+ $container->make($abstract),
+ "The $abstract is not an instance of $concrete."
+ );
+ }
+ }
+}
diff --git a/tests/ServiceProviders/LoggerServiceProviderTest.php b/tests/ServiceProviders/LoggerServiceProviderTest.php
new file mode 100644
index 0000000..beb389a
--- /dev/null
+++ b/tests/ServiceProviders/LoggerServiceProviderTest.php
@@ -0,0 +1,15 @@
+bind(SWConfig::class, function () {
+ return SWConfig::load(__DIR__ . '/../config.php');
+ });
}
protected function tearDown(): void
{
Config::clearResolvedInstances();
- Facade::setFacadeApplication(null);
+ Facade::setFacadeContainer(null);
}
}