Ejemplo n.º 1
0
 /**
  * Tests the Rox_Helper_Pagination::links() method with options
  *
  * @return void
  */
 public function testLinksWithOptions()
 {
     /*
       collection    = empty Array
       pages         = 20
       current page  = 3
       next page     = 4
       previous page = 2
     */
     $paginationResult = new PaginationResult(array(), 20, 3, 4, 2, 40);
     $paginationHelper = new Pagination();
     $result = $paginationHelper->links($paginationResult, array('class' => 'my-custom-pagination-class', 'prev_label' => 'My Prev Label', 'next_label' => 'My Next Label', 'max_items' => 10));
     $this->assertContains('<div class="my-custom-pagination-class">', $result);
     $this->assertContains('<a href="?page=2" rel="prev" class="prev-page">My Prev Label</a>', $result);
     $this->assertContains('<a href="?page=4" rel="next" class="next-page">My Next Label</a>', $result);
     // Last page link
     $this->assertContains('<a href="?page=20">20</a>', $result);
     $this->assertContains('<span>...</span>', $result);
 }
Ejemplo n.º 2
0
	/**
	 * Tests the Rox_Helper_Pagination::links() method with options
	 *
	 * @return void
	 */
	public function testLinksWithOptions() {
		/*
		   collection    = empty Array
		   pages         = 20
		   current page  = 3
		   next page     = 4
		   previous page = 2
		 */
		$paginationResult = new PaginationResult(array(), 20, 3, 4, 2, 40);
		$paginationHelper = new Pagination;

		$result = $paginationHelper->links($paginationResult, array(
			'class'          => 'my-custom-pagination-class',
			'prev_label' => 'My Prev Label',
			'next_label'     => 'My Next Label',
			'max_items'      => 10
		));

		$matcher = array(
			'tag' => 'div',
			'attributes' => array(
				'class' => 'my-custom-pagination-class'
			)
		);

		$this->assertTag($matcher, $result);
	
		// Next page link
		$matcher = array(
			'tag' => 'a',
			'parent' => array('tag' => 'div'),
			'content' => 'My Prev Label'
		);

		$this->assertTag($matcher, $result);

		// Previous page link
		$matcher = array(
			'tag' => 'a',
			'parent' => array('tag' => 'div'),
			'content' => 'My Next Label'
		);

		$this->assertTag($matcher, $result);

		// Last page link
		$matcher = array(
			'tag' => 'a',
			'parent' => array('tag' => 'div'),
			'content' => '20',
			'attributes' => array(
				'href' => '?page=20'
			)
		);

		$this->assertTag($matcher, $result);

		$matcher = array(
			'tag' => 'div',
			'child' => array(
				'tag'     => 'span',
				'content' => '...',
			)
		);

		$this->assertTag($matcher, $result);

		$matcher = array(
			'tag' => 'a',
			'content' => '11'
		);

		$this->assertNotTag($matcher, $result);
	}