/** * get Options transformed * * @return array */ protected function getOptions() { $options = $this->options ? $this->options->toArray() : []; if ($this->topic && !$this->topic->hasOnlyOneTopic()) { $options = array_merge($options, $this->topic->build()); } return $options; }
/** * @test */ public function it_has_a_complex_topic_condition() { $target = ['condition' => "'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics) || ('TopicD' in topics && 'TopicE' in topics)"]; $topics = new Topics(); $topics->topic('TopicA')->andTopic(function ($condition) { $condition->topic('TopicB')->orTopic('TopicC'); })->orTopic(function ($condition) { $condition->topic('TopicD')->andTopic('TopicE'); }); $this->assertEquals($target, $topics->build()); }