From 0d2c90cd8eadddd7cd10a5e2c200fe0c24dad2ff Mon Sep 17 00:00:00 2001 From: Dib Abdelkrim Date: Mon, 16 May 2016 16:52:32 +0100 Subject: [PATCH 1/5] adding support to database mocking --- .../Providers/HerbertServiceProvider.php | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Herbert/Framework/Providers/HerbertServiceProvider.php b/Herbert/Framework/Providers/HerbertServiceProvider.php index 6bb5826..2804446 100644 --- a/Herbert/Framework/Providers/HerbertServiceProvider.php +++ b/Herbert/Framework/Providers/HerbertServiceProvider.php @@ -128,16 +128,26 @@ protected function registerEloquent() $capsule = new Capsule($this->app); - $capsule->addConnection([ - 'driver' => 'mysql', - 'host' => DB_HOST, - 'database' => DB_NAME, - 'username' => DB_USER, - 'password' => DB_PASSWORD, - 'charset' => DB_CHARSET, - 'collation' => DB_COLLATE ?: $wpdb->collate, - 'prefix' => $wpdb->prefix - ]); + if (defined('WP_MUFFIN') && WP_MUFFIN) { + $capsule->addConnection([ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'charset' => DB_CHARSET, + 'collation' => DB_COLLATE ?: $wpdb->collate, + 'prefix' => $wpdb->prefix + ]); + } else { + $capsule->addConnection([ + 'driver' => 'mysql', + 'host' => DB_HOST, + 'database' => DB_NAME, + 'username' => DB_USER, + 'password' => DB_PASSWORD, + 'charset' => DB_CHARSET, + 'collation' => DB_COLLATE ?: $wpdb->collate, + 'prefix' => $wpdb->prefix + ]); + } $capsule->setAsGlobal(); $capsule->bootEloquent(); From 4bef6208abc7001bd2ef0cb33c17d73e8d5a79ec Mon Sep 17 00:00:00 2001 From: Dib Abdelkrim Date: Mon, 16 May 2016 16:53:58 +0100 Subject: [PATCH 2/5] add a check to the routes array before foreach --- Herbert/Framework/Router.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Herbert/Framework/Router.php b/Herbert/Framework/Router.php index 5b41a07..fe1f91f 100644 --- a/Herbert/Framework/Router.php +++ b/Herbert/Framework/Router.php @@ -95,9 +95,11 @@ public function boot() { add_rewrite_tag('%herbert_route%', '(.+)'); - foreach ($this->routes[$this->http->method()] as $id => $route) - { - $this->addRoute($route, $id, $this->http->method()); + if(is_array($this->routes[$this->http->method()])) { + foreach ($this->routes[$this->http->method()] as $id => $route) + { + $this->addRoute($route, $id, $this->http->method()); + } } } From d102cda32623cf7df39987868d3825a712aded06 Mon Sep 17 00:00:00 2001 From: Dib Abdelkrim Date: Mon, 16 May 2016 16:55:01 +0100 Subject: [PATCH 3/5] fix the shortcode issus when using closure --- Herbert/Framework/Shortcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Herbert/Framework/Shortcode.php b/Herbert/Framework/Shortcode.php index 4e99072..25b65b4 100644 --- a/Herbert/Framework/Shortcode.php +++ b/Herbert/Framework/Shortcode.php @@ -41,7 +41,7 @@ public function add($name, $callable, $arguments = []) $attributes = $this->renameArguments($arguments, $attributes); } - if (strpos($callable, '::') !== false) + if (is_string($callable) && strpos($callable, '::') !== false) { list($api, $method) = explode('::', $callable); From 92cfa2f112e43b5515fca9627843883528ed01b8 Mon Sep 17 00:00:00 2001 From: Dib Abdelkrim Date: Mon, 16 May 2016 17:03:38 +0100 Subject: [PATCH 4/5] fix twig permission issus --- Herbert/Framework/Providers/TwigServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Herbert/Framework/Providers/TwigServiceProvider.php b/Herbert/Framework/Providers/TwigServiceProvider.php index beb4afb..cce2573 100644 --- a/Herbert/Framework/Providers/TwigServiceProvider.php +++ b/Herbert/Framework/Providers/TwigServiceProvider.php @@ -20,7 +20,7 @@ public function register() { $this->app->singleton('twig.loader', function () { - $loader = new Twig_Loader_Filesystem('/'); + $loader = new Twig_Loader_Filesystem(); foreach ($this->app->getPlugins() as $plugin) { From 30dde82a59f02fecb5281d8f00c7edff2bc46615 Mon Sep 17 00:00:00 2001 From: Dib Abdelkrim Date: Sun, 19 Jun 2016 18:39:47 +0100 Subject: [PATCH 5/5] fix OPTIONS --- Herbert/Framework/Router.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Herbert/Framework/Router.php b/Herbert/Framework/Router.php index fe1f91f..5b41a07 100644 --- a/Herbert/Framework/Router.php +++ b/Herbert/Framework/Router.php @@ -95,11 +95,9 @@ public function boot() { add_rewrite_tag('%herbert_route%', '(.+)'); - if(is_array($this->routes[$this->http->method()])) { - foreach ($this->routes[$this->http->method()] as $id => $route) - { - $this->addRoute($route, $id, $this->http->method()); - } + foreach ($this->routes[$this->http->method()] as $id => $route) + { + $this->addRoute($route, $id, $this->http->method()); } }