/**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = ['captcha', 'required'];
     $rules[] = ['captcha', 'captcha'];
     return $rules;
 }
 public function test_scenario3()
 {
     $data = array(array("filename" => "data/spam.csv", "local_file" => "tmp/if_then_rules_spam_textanalysis_1.txt", "expected_file" => "data/model/if_then_rules_spam_textanalysis_1.txt", "options" => array("fields" => array("000001" => array("optype" => "text", "term_analysis" => array("case_sensitive" => true, "stem_words" => true, "use_stopwords" => false, "language" => "en"))))), array("filename" => "data/spam.csv", "local_file" => "tmp/if_then_rules_spam_textanalysis_2.txt", "expected_file" => "data/model/if_then_rules_spam_textanalysis_2.txt", "options" => array("fields" => array("000001" => array("optype" => "text", "term_analysis" => array("case_sensitive" => true, "stem_words" => true, "use_stopwords" => false))))), array("filename" => "data/spam.csv", "local_file" => "tmp/if_then_rules_spam_textanalysis_3.txt", "expected_file" => "data/model/if_then_rules_spam_textanalysis_3.txt", "options" => array("fields" => array("000001" => array("optype" => "text", "term_analysis" => array("case_sensitive" => false, "stem_words" => false, "use_stopwords" => false, "language" => "en"))))), array("filename" => "data/spam.csv", "local_file" => "tmp/if_then_rules_spam_textanalysis_4.txt", "expected_file" => "data/model/if_then_rules_spam_textanalysis_4.txt", "options" => array("fields" => array("000001" => array("optype" => "text", "term_analysis" => array("case_sensitive" => false, "stem_words" => true, "use_stopwords" => true, "language" => "en"))))), array("filename" => "data/spam.csv", "local_file" => "tmp/if_then_rules_spam_textanalysis_5.txt", "expected_file" => "data/model/if_then_rules_spam_textanalysis_5.txt", "options" => array("fields" => array("000001" => array("optype" => "text", "term_analysis" => array("token_mode" => "full_terms_only", "language" => "en"))))));
     foreach ($data as $item) {
         print "\nSuccessfully creating a model and translate the tree model into a set of IF-THEN rules\n";
         print "Given I create a data source uploading a " . $item["filename"] . " file\n";
         $source = self::$api->create_source($item["filename"], $options = array('name' => 'local_test_source', 'project' => self::$project->resource));
         $this->assertEquals(BigMLRequest::HTTP_CREATED, $source->code);
         $this->assertEquals(1, $source->object->status->code);
         print "And I wait until the source is ready\n";
         $resource = self::$api->_check_resource($source->resource, null, 10000, 30);
         $this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
         print "And I update the source with options " . json_encode($item["options"]) . "\n";
         $source = self::$api->update_source($source->resource, $item["options"]);
         $this->assertEquals(BigMLRequest::HTTP_ACCEPTED, $source->code);
         print "And I create dataset with local source\n";
         $dataset = self::$api->create_dataset($source->resource);
         $this->assertEquals(BigMLRequest::HTTP_CREATED, $dataset->code);
         $this->assertEquals(BigMLRequest::QUEUED, $dataset->object->status->code);
         print "And I wait until the dataset is ready\n";
         $resource = self::$api->_check_resource($dataset->resource, null, 10000, 30);
         $this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
         print "And I create model\n";
         $model = self::$api->create_model($dataset->resource);
         $this->assertEquals(BigMLRequest::HTTP_CREATED, $model->code);
         print "And I wait until the model is ready " . $model->resource . "\n";
         $resource = self::$api->_check_resource($model->resource, null, 10000, 30);
         $this->assertEquals(BigMLRequest::FINISHED, $resource["status"]);
         print "And I create a local model\n";
         $local_model = new Model($model->resource, self::$api);
         print "And I translate the tree into IF_THEN rules\n";
         $fp = fopen($item["local_file"], 'w');
         $local_model->rules($fp);
         print " Then I check the output is like " . $item["expected_file"] . " expected file\n";
         $this->assertTrue(compareFiles($item["local_file"], $item["expected_file"]));
     }
 }