コード例 #1
0
 public function testRecordsAreSorted()
 {
     $item1 = new SortableItem();
     $item1->save();
     $item2 = new SortableItem();
     $item2->save();
     $this->assertTrue($item1->position < $item2->position);
 }
コード例 #2
0
ファイル: SortableTest.php プロジェクト: kenarkose/sortable
 /** @test */
 function it_calls_special_sortable_function()
 {
     try {
         SortableItem::sortable('special_key', 'asc');
     } catch (\Exception $e) {
         if ($e->getMessage() === 'special_key') {
             return;
         }
     }
     $this->fail('Special function not called, test fails.');
 }
コード例 #3
0
 public function testReorderArray()
 {
     $item1 = new SortableItem();
     $item1->save();
     $item2 = new SortableItem();
     $item2->save();
     $item3 = new SortableItem();
     $item3->save();
     $item4 = new SortableItem();
     $item4->save();
     $item5 = new SortableItem();
     $item5->save();
     $new_order = array($item4->id, $item2->id, $item1->id, $item5->id, $item3->id);
     $check_order = array($item4->refresh()->id, $item2->refresh()->id, $item1->refresh()->id, $item5->refresh()->id, $item3->refresh()->id);
 }
コード例 #4
0
 public function testFindFirstAndLast()
 {
     parent::prepareTables();
     $item1 = new SortableItem();
     $item1->save();
     $item2 = new SortableItem();
     $item2->save();
     $this->assertEqual($item1->id, Doctrine::getTable('SortableItem')->findFirst()->id);
     $this->assertEqual($item2->id, Doctrine::getTable('SortableItem')->findLast()->id);
 }
コード例 #5
0
ファイル: SupporterTest.php プロジェクト: kenarkose/sortable
 /** @test */
 function it_generates_sortable_active_links()
 {
     SortableItem::sortable();
     $supporter = $this->getSupporter();
     $this->assertEquals('<a title="Title" class="sortable-link sortable-link--asc sortable-link--active" href="http://localhost?s=id&d=desc">Text</a>', $supporter->generateLinkFor('id', 'Text', 'Title'));
 }