Exemplo 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);
 }
 public function tearDown()
 {
     TestModel::deleteTable();
     TestModelExtendedTypes::deleteTable();
     TestModelWithNameLabel::deleteTable();
     TestModelSortable::deleteTable();
     TestModelSearchOnly::deleteTable();
 }
Exemplo n.º 3
0
 public function setUp()
 {
     $this->base = new \Thru\ActiveRecord\DatabaseLayer\Sql\Base();
     $this->mysql = new \Thru\ActiveRecord\DatabaseLayer\Sql\Mysql();
     TestModel::deleteTable();
     TestModelExtendedTypes::deleteTable();
     TestModelWithNameLabel::deleteTable();
     TestModelSortable::deleteTable();
     TestModelSearchOnly::deleteTable();
 }
Exemplo n.º 4
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");
 }
Exemplo n.º 5
0
 public function testLabelManual()
 {
     $model = new TestModelWithNameLabel();
     $model->something_else = 'foo';
     $this->assertEquals("foo", $model->getLabel());
 }