diff --git a/src/core/Core.php b/src/core/Core.php new file mode 100644 index 0000000..b83e952 --- /dev/null +++ b/src/core/Core.php @@ -0,0 +1,73 @@ +initTwig(); + $this->initDatabase(); + } + + private function initTwig():void{ + $loader = new \Twig_Loader_Filesystem(__DIR__.'/../template'); + $this->twig = new \Twig_Environment($loader); + } + + private function initDatabase():void{ + $this->database = new \PDO('mysql:host='.self::DATABASE_HOST.';dbname='.self::DATABASE_NAME.';port='.self::DATABASE_PORT, self::DATABASE_USERNAME, self::DATABASE_PASSWORD); + } + + public function getDatabase(): \PDO + { + return $this->database; + } + + public function getTwig(): \Twig_Environment + { + return $this->twig; + } + + public function getUser(): ?UserInterface + { + return $this->user; + } + + public function setUser(?UserInterface $user = null): void + { + $this->user = $user; + } + +} + diff --git a/src/core/CoreInterface.php b/src/core/CoreInterface.php new file mode 100644 index 0000000..30b14f8 --- /dev/null +++ b/src/core/CoreInterface.php @@ -0,0 +1,21 @@ +core = new Core(); + $this->user = new User(); + $this->core->setUser($this->user); + } + + public function testTwig():void{ + $this->assertInstanceOf(\Twig_Environment::class, $this->core->getTwig()); + } + + public function testDatabase():void{ + $this->assertInstanceOf(\PDO::class, $this->core->getDatabase()); + } + + public function testUser():void{ + $this->assertEquals($this->user, $this->core->getUser()); + } +} +