From 1f440bafad2b93d84e9f200ea18172f5db8b99d8 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Tue, 12 Dec 2017 11:40:01 -0200 Subject: [PATCH] add publish to factory param --- tests/factories/class-tainacan-entity-factory.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/factories/class-tainacan-entity-factory.php b/tests/factories/class-tainacan-entity-factory.php index b9a7ba472..264b8d65f 100644 --- a/tests/factories/class-tainacan-entity-factory.php +++ b/tests/factories/class-tainacan-entity-factory.php @@ -29,7 +29,7 @@ class Entity_Factory { * @return mixed * @throws \ErrorException */ - public function create_entity($type, $args = [], $is_validated_and_in_db = false){ + public function create_entity($type, $args = [], $is_validated_and_in_db = false, $publish = false){ ini_set('display_errors', 1); try { @@ -54,6 +54,11 @@ class Entity_Factory { $this->entity = new $this->entity_type(); $this->repository = new $this->repository_type(); + + if($publish) + { + $this->entity->set_status('publish'); + } if (!empty($args) && $is_validated_and_in_db) { foreach ($args as $attribute => $content) { @@ -116,7 +121,7 @@ class Entity_Factory { } catch (\Error $exception){ echo "\n" . $exception->getMessage() . "\n"; } - + return $this->entity; } }