diff --git a/Localization/BaseStringL11nType.php b/Localization/BaseStringL11nType.php index 789251043..a661f618e 100644 --- a/Localization/BaseStringL11nType.php +++ b/Localization/BaseStringL11nType.php @@ -40,6 +40,14 @@ class BaseStringL11nType implements \JsonSerializable */ public string $title = ''; + /* + * String l11n + * + * @var string | BaseStringL11n + * @since 1.0.0 + */ + public string | BaseStringL11n $l11n = ''; + /** * Is the l11n type required for an item? * @@ -72,6 +80,44 @@ class BaseStringL11nType implements \JsonSerializable return $this->id; } + /** + * Set l11n + * + * @param string|BaseStringL11n $l11n Tag article l11n + * @param string $lang Language + * + * @return void + * + * @since 1.0.0 + */ + public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void + { + if ($l11n instanceof BaseStringL11n) { + $this->l11n = $l11n; + } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { + $this->l11n->content = $l11n; + $this->l11n->setLanguage($lang); + } else { + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->setLanguage($lang); + } + } + + /** + * @return string + * + * @since 1.0.0 + */ + public function getL11n() : string + { + if (!isset($this->l11n)) { + return ''; + } + + return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n; + } + /** * {@inheritdoc} */ diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index af7d2b229..b823d4f21 100755 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -275,7 +275,7 @@ final class L11nManager int $divide = 1 ) : string { - $language = $l11n->getLanguage(); + $language = $l11n->language; $symbol ??= $l11n->getCurrency(); if (\is_float($currency)) { diff --git a/Localization/Localization.php b/Localization/Localization.php index 286dbd3c7..d7456c5a3 100755 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -347,18 +347,6 @@ class Localization implements \JsonSerializable $this->setDatetime($locale['datetime'] ?? []); } - /** - * Get country - * - * @return string - * - * @since 1.0.0 - */ - public function getCountry() : string - { - return $this->country; - } - /** * Set country name * @@ -409,18 +397,6 @@ class Localization implements \JsonSerializable $this->timezone = $timezone; } - /** - * Get language - * - * @return string - * - * @since 1.0.0 - */ - public function getLanguage() : string - { - return $this->language; - } - /** * Set language code * diff --git a/Message/Cli/CliResponse.php b/Message/Cli/CliResponse.php index dcee7a9b7..640a44cc8 100755 --- a/Message/Cli/CliResponse.php +++ b/Message/Cli/CliResponse.php @@ -65,7 +65,7 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface */ public function setResponse(array $response) : void { - $this->response = $response; + $this->data = $response; } /** @@ -79,8 +79,8 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface */ public function remove(string $id) : bool { - if (isset($this->response[$id])) { - unset($this->response[$id]); + if (isset($this->data[$id])) { + unset($this->data[$id]); return true; } @@ -134,7 +134,7 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface { $render = ''; - foreach ($this->response as $response) { + foreach ($this->data as $response) { $render .= StringUtils::stringify($response); } @@ -148,7 +148,7 @@ final class CliResponse extends ResponseAbstract implements RenderableInterface { $result = []; - foreach ($this->response as $response) { + foreach ($this->data as $response) { if ($response instanceof View) { $result[] = $response->toArray(); } elseif (\is_array($response) || \is_scalar($response)) { diff --git a/Message/Http/HttpRequest.php b/Message/Http/HttpRequest.php index c571f27b6..030ada013 100755 --- a/Message/Http/HttpRequest.php +++ b/Message/Http/HttpRequest.php @@ -404,7 +404,7 @@ final class HttpRequest extends RequestAbstract public function getLocale() : string { if (!empty($this->locale)) { - return $this->locale = $this->header->l11n->getLanguage() . '_' . $this->header->l11n->getCountry(); + return $this->locale = $this->header->l11n->language . '_' . $this->header->l11n->getCountry(); } if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { diff --git a/Message/Http/HttpResponse.php b/Message/Http/HttpResponse.php index 2995813ea..f8a6c50c3 100755 --- a/Message/Http/HttpResponse.php +++ b/Message/Http/HttpResponse.php @@ -59,7 +59,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface */ public function setResponse(array $response) : void { - $this->response = $response; + $this->data = $response; } /** @@ -73,8 +73,8 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface */ public function remove(string $id) : bool { - if (isset($this->response[$id])) { - unset($this->response[$id]); + if (isset($this->data[$id])) { + unset($this->data[$id]); return true; } @@ -143,7 +143,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface private function getRaw(bool $optimize = false) : string { $render = ''; - foreach ($this->response as $response) { + foreach ($this->data as $response) { // @note: Api functions return void -> null, this is where the null value is "ignored"/rendered as '' $render .= StringUtils::stringify($response); } @@ -183,7 +183,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface { $result = []; - foreach ($this->response as $response) { + foreach ($this->data as $response) { if ($response instanceof View) { $result[] = $response->toArray(); } elseif (\is_array($response) || \is_scalar($response)) { diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 246863c02..22ffc5ad3 100755 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -40,7 +40,7 @@ abstract class RequestAbstract implements MessageInterface * @var array * @since 1.0.0 */ - protected array $data = []; + public array $data = []; /** * Files data. @@ -48,7 +48,7 @@ abstract class RequestAbstract implements MessageInterface * @var array * @since 1.0.0 */ - protected array $files = []; + public array $files = []; /** * Request lock. @@ -124,18 +124,6 @@ abstract class RequestAbstract implements MessageInterface } } - /** - * Get data. - * - * @return array - * - * @since 1.0.0 - */ - public function getDataArray() : array - { - return $this->data; - } - /** * Get data. * @@ -380,30 +368,6 @@ abstract class RequestAbstract implements MessageInterface $this->lock = true; } - /** - * Get request language. - * - * @return string - * - * @since 1.0.0 - */ - public function getLanguage() : string - { - return $this->header->l11n->getLanguage(); - } - - /** - * Get request language. - * - * @return string - * - * @since 1.0.0 - */ - public function getCountry() : string - { - return $this->header->l11n->getCountry(); - } - /** * Get request hash. * @@ -442,44 +406,6 @@ abstract class RequestAbstract implements MessageInterface return $this->uri->__toString(); } - /** - * Get files. - * - * @return array - * - * @since 1.0.0 - */ - public function getFiles() : array - { - return $this->files; - } - - /** - * Get files by name. - * - * @param string $name File name - * - * @return array - * - * @since 1.0.0 - */ - public function getFile(string $name) : array - { - return $this->files[$name] ?? []; - } - - /** - * Has files. - * - * @return bool - * - * @since 1.0.0 - */ - public function hasFiles() : bool - { - return !empty($this->files); - } - /** * Add file to request * diff --git a/Message/ResponseAbstract.php b/Message/ResponseAbstract.php index 0d109152f..6b5e8b752 100755 --- a/Message/ResponseAbstract.php +++ b/Message/ResponseAbstract.php @@ -32,7 +32,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface * @var array * @since 1.0.0 */ - protected array $response = []; + public array $data = []; /** * Header. @@ -53,7 +53,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface */ public function get(mixed $id) : mixed { - return $this->response[$id] ?? null; + return $this->data[$id] ?? null; } /** @@ -69,9 +69,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface */ public function set(mixed $key, mixed $response, bool $overwrite = false) : void { - // This is not working since the key contains :: from http:// - //$this->response = ArrayUtils::setArray((string) $key, $this->response, $response, ':', $overwrite); - $this->response[$key] = $response; + $this->data[$key] = $response; } /** @@ -106,7 +104,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface return ISO639x1Enum::_EN; } - return $this->header->l11n->getLanguage(); + return $this->header->l11n->language; } /** diff --git a/Message/Socket/SocketResponse.php b/Message/Socket/SocketResponse.php index 2dd4b85a9..16d30ddfd 100755 --- a/Message/Socket/SocketResponse.php +++ b/Message/Socket/SocketResponse.php @@ -42,7 +42,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa */ public function setResponse(array $response) : void { - $this->response = $response; + $this->data = $response; } /** @@ -56,8 +56,8 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa */ public function remove($id) : bool { - if (isset($this->response[$id])) { - unset($this->response[$id]); + if (isset($this->data[$id])) { + unset($this->data[$id]); return true; } @@ -118,7 +118,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa { $render = ''; - foreach ($this->response as $key => $response) { + foreach ($this->data as $key => $response) { $render .= StringUtils::stringify($response); } @@ -157,7 +157,7 @@ final class SocketResponse extends ResponseAbstract implements RenderableInterfa { $result = []; - foreach ($this->response as $response) { + foreach ($this->data as $response) { if ($response instanceof View) { $result[] = $response->toArray(); } elseif (\is_array($response) || \is_scalar($response)) { diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index 0f1e792a3..7980d1043 100755 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -71,7 +71,7 @@ abstract class ModuleAbstract * @var string[] * @since 1.0.0 */ - protected static array $providing = []; + public static array $providing = []; /** * Dependencies. @@ -79,7 +79,7 @@ abstract class ModuleAbstract * @var string[] * @since 1.0.0 */ - protected static array $dependencies = []; + public static array $dependencies = []; /** * Receiving modules from? @@ -87,7 +87,7 @@ abstract class ModuleAbstract * @var string[] * @since 1.0.0 */ - protected array $receiving = []; + public array $receiving = []; /** * Application instance. @@ -220,12 +220,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => $status, 'title' => $title, 'message' => $message, 'response' => $obj, - ]); + ]; } /** @@ -246,12 +246,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::OK, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulCreate'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulCreate'), 'response' => $obj, - ]); + ]; } /** @@ -272,12 +272,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::OK, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulUpdate'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulUpdate'), 'response' => $obj, - ]); + ]; } /** @@ -298,12 +298,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::OK, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulDelete'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulDelete'), 'response' => $obj, - ]); + ]; } /** @@ -324,12 +324,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::OK, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulRemove'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulRemove'), 'response' => $obj, - ]); + ]; } /** @@ -350,12 +350,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::OK, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulReturn'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulReturn'), 'response' => $obj, - ]); + ]; } /** @@ -376,12 +376,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::OK, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SuccessfulAdd'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SuccessfulAdd'), 'response' => $obj, - ]); + ]; } /** @@ -402,12 +402,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::WARNING, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidCreate'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidCreate'), 'response' => $obj, - ]); + ]; } /** @@ -428,12 +428,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::WARNING, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidUpdate'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidUpdate'), 'response' => $obj, - ]); + ]; } /** @@ -454,12 +454,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::WARNING, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidDelete'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidDelete'), 'response' => $obj, - ]); + ]; } /** @@ -480,12 +480,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::WARNING, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidRemove'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidRemove'), 'response' => $obj, - ]); + ]; } /** @@ -506,12 +506,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::WARNING, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidReturn'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidReturn'), 'response' => $obj, - ]); + ]; } /** @@ -532,12 +532,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::WARNING, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidAdd'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidAdd'), 'response' => $obj, - ]); + ]; } /** @@ -558,12 +558,12 @@ abstract class ModuleAbstract ) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), [ + $response->data[$request->uri->__toString()] = [ 'status' => NotificationLevel::WARNING, 'title' => '', - 'message' => $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'InvalidPermission'), + 'message' => $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'InvalidPermission'), 'response' => $obj, - ]); + ]; } /** @@ -580,7 +580,7 @@ abstract class ModuleAbstract protected function fillJsonRawResponse(RequestAbstract $request, ResponseAbstract $response, mixed $obj) : void { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->uri->__toString(), $obj); + $response->data[$request->uri->__toString()] = $obj; } /** diff --git a/Views/View.php b/Views/View.php index 5d7c95598..fe70239f8 100755 --- a/Views/View.php +++ b/Views/View.php @@ -39,7 +39,7 @@ class View extends ViewAbstract * @var array * @since 1.0.0 */ - protected array $data = []; + public array $data = []; /** * View Localization. @@ -47,7 +47,7 @@ class View extends ViewAbstract * @var Localization * @since 1.0.0 */ - protected Localization $l11n; + public Localization $l11n; /** * Application. @@ -55,7 +55,7 @@ class View extends ViewAbstract * @var L11nManager * @since 1.0.0 */ - protected L11nManager $l11nManager; + public L11nManager $l11nManager; /** * Request. @@ -216,7 +216,7 @@ class View extends ViewAbstract /** @var string $theme */ $theme = $theme ?? $this->theme; - return $this->l11nManager->getText($this->l11n->getLanguage(), $module, $theme, $translation); + return $this->l11nManager->getText($this->l11n->language, $module, $theme, $translation); } /** diff --git a/tests/Message/Cli/CliRequestTest.php b/tests/Message/Cli/CliRequestTest.php index f69673b60..0fe514e1e 100755 --- a/tests/Message/Cli/CliRequestTest.php +++ b/tests/Message/Cli/CliRequestTest.php @@ -42,7 +42,7 @@ final class CliRequestTest extends \PHPUnit\Framework\TestCase public function testDefault() : void { $request = new CliRequest(); - self::assertEquals('en', $request->getLanguage()); + self::assertEquals('en', $request->header->l11n->language); self::assertEquals(OSType::LINUX, $request->getOS()); self::assertEquals('127.0.0.1', $request->getOrigin()); self::assertEmpty($request->getBody()); diff --git a/tests/Message/Http/HttpRequestLanguage.php b/tests/Message/Http/HttpRequestLanguage.php index 9bdb12c00..9a24b3b8f 100755 --- a/tests/Message/Http/HttpRequestLanguage.php +++ b/tests/Message/Http/HttpRequestLanguage.php @@ -7,4 +7,4 @@ use phpOMS\Message\Http\HttpRequest; $request = HttpRequest::createFromSuperglobals(); -echo $request->getCountry(); +echo $request->header->l11n->country; diff --git a/tests/Message/Http/HttpRequestTest.php b/tests/Message/Http/HttpRequestTest.php index b26dd3993..021d63f5f 100755 --- a/tests/Message/Http/HttpRequestTest.php +++ b/tests/Message/Http/HttpRequestTest.php @@ -43,7 +43,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase $_SERVER['HTTP_USER_AGENT'] = OSType::UNKNOWN . BrowserType::UNKNOWN; - self::assertEquals('en', $request->getLanguage()); + self::assertEquals('en', $request->header->l11n->language); self::assertFalse($request->isMobile()); self::assertEquals(BrowserType::UNKNOWN, $request->getBrowser()); self::assertEquals(OSType::UNKNOWN, $request->getOS()); @@ -51,7 +51,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase self::assertFalse(HttpRequest::isHttps()); self::assertEquals([], $request->getHash()); self::assertEmpty($request->getBody()); - self::assertEmpty($request->getFiles()); + self::assertEmpty($request->files); self::assertEquals(RouteVerb::GET, $request->getRouteVerb()); self::assertEquals(RequestMethod::GET, $request->getMethod()); self::assertInstanceOf('\phpOMS\Message\Http\HttpHeader', $request->header); @@ -59,7 +59,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $request->__toString()); self::assertFalse($request->hasData('key')); self::assertNull($request->getData('key')); - self::assertEquals('en', $request->getCountry()); + self::assertEquals('en', $request->header->l11n->country); self::assertEquals('en_US', $request->getLocale()); } @@ -162,7 +162,7 @@ final class HttpRequestTest extends \PHPUnit\Framework\TestCase $request->header->l11n = new Localization(); $request->header->l11n->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $request->getLanguage()); + self::assertEquals(ISO639x1Enum::_DE, $request->header->l11n->language); } /** diff --git a/tests/Message/Http/HttpResponseTest.php b/tests/Message/Http/HttpResponseTest.php index a91a6398f..581312498 100755 --- a/tests/Message/Http/HttpResponseTest.php +++ b/tests/Message/Http/HttpResponseTest.php @@ -115,7 +115,7 @@ final class HttpResponseTest extends \PHPUnit\Framework\TestCase $this->response->header->l11n = new Localization(); $this->response->header->l11n->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $this->response->getLanguage()); + self::assertEquals(ISO639x1Enum::_DE, $this->response->header->l11n->language); } /** diff --git a/tests/Message/ResponseAbstractTest.php b/tests/Message/ResponseAbstractTest.php index 2460af20c..d81d3a09a 100755 --- a/tests/Message/ResponseAbstractTest.php +++ b/tests/Message/ResponseAbstractTest.php @@ -56,7 +56,7 @@ final class ResponseAbstractTest extends \PHPUnit\Framework\TestCase { self::assertNull($this->response->get('asdf')); self::assertEquals('', $this->response->getBody()); - self::assertTrue(ISO639x1Enum::isValidValue($this->response->getLanguage())); + self::assertTrue(ISO639x1Enum::isValidValue($this->response->header->l11n->language)); } /** diff --git a/tests/Views/ViewTest.php b/tests/Views/ViewTest.php index d07d356be..0b9cb1786 100755 --- a/tests/Views/ViewTest.php +++ b/tests/Views/ViewTest.php @@ -83,7 +83,7 @@ final class ViewTest extends \PHPUnit\Framework\TestCase public function testHasData() : void { $view = new View($this->app->l11nManager); - $view->addData('a', 1); + $view->data['a'] = 1; self::assertTrue($view->hasData('a')); self::assertFalse($view->hasData('b')); @@ -201,7 +201,7 @@ final class ViewTest extends \PHPUnit\Framework\TestCase { $view = new View($this->app->l11nManager); - $view->setData('key', 'value'); + $view->data['key'] = 'value'; self::assertEquals('value', $view->getData('key')); } @@ -214,7 +214,7 @@ final class ViewTest extends \PHPUnit\Framework\TestCase { $view = new View($this->app->l11nManager); - self::assertTrue($view->addData('key2', 'valu2')); + self::assertTrue($view->data['key2'] = 'valu2'); self::assertEquals('valu2', $view->getData('key2')); } @@ -227,8 +227,8 @@ final class ViewTest extends \PHPUnit\Framework\TestCase { $view = new View($this->app->l11nManager); - $view->addData('key2', 'valu2'); - self::assertFalse($view->addData('key2', 'valu3')); + $view->data['key2'] = 'valu2'; + self::assertFalse($view->data['key2'] = 'valu3'); self::assertEquals('valu2', $view->getData('key2')); } @@ -241,7 +241,7 @@ final class ViewTest extends \PHPUnit\Framework\TestCase { $view = new View($this->app->l11nManager); - $view->addData('key2', 'valu2'); + $view->data['key2'] = 'valu2'; self::assertTrue($view->removeData('key2')); }