Ejemplo n.º 1
0
 public function testSearchBySlug()
 {
     $slug_original = new TestModelWithNameLabel();
     $slug_original->name = "Bleh";
     $slug_original->something_else = "Example";
     $slug_original->save();
     $this->assertStringMatchesFormat("%d-example", $slug_original->getSlug());
     $slug_searched = TestModelWithNameLabel::getBySlug($slug_original->getSlug());
     $this->assertNotFalse($slug_searched);
     $this->assertEquals($slug_original->test_model_with_label_id, $slug_searched->test_model_with_label_id);
 }
Ejemplo n.º 2
0
 /**
  * @depends testSearchOneResult
  * @param \Thru\ActiveRecord\Test\Models\TestModel $test_model
  */
 public function testLabels(TestModel $test_model)
 {
     $this->assertEquals("No label for Thru\\ActiveRecord\\Test\\Models\\TestModel ID 1", $test_model->getLabel());
     $with_name_label = new \Thru\ActiveRecord\Test\Models\TestModelWithNameLabel();
     $with_name_label->name = "Wrong name here";
     $with_name_label->something_else = "Right name here";
     $with_name_label->save();
     $this->assertEquals($with_name_label->something_else, $with_name_label->getLabel(), "Name label works");
 }