[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/tests/phpunit/testcases/core/template/ -> bpCreateExcerpt.php (source)

   1  <?php
   2  
   3  /**
   4   * @group core
   5   * @group bp_create_excerpt
   6   */
   7  class BP_Tests_Core_Template_BPCreateExcerpt extends BP_UnitTestCase {
   8  	public function test_should_ignore_html_tag_when_html_true() {
   9          $text = 'foo <hr> bar baz';
  10          $expected = 'foo <hr /> bar';
  11          $this->assertSame( $expected, bp_create_excerpt( $text, 8, array(
  12              'ending' => '',
  13              'html' => true,
  14              'exact' => true,
  15          ) ) );
  16      }
  17  
  18      /**
  19       * @ticket BP3680
  20       */
  21      public function test_should_ignore_single_word_html_comments_when_html_true() {
  22          $text = 'foo <!--more--> bar baz';
  23          $expected = 'foo <!--more--> bar';
  24          $this->assertSame( $expected, bp_create_excerpt( $text, 8, array(
  25              'ending' => '',
  26              'html' => true,
  27              'exact' => true,
  28          ) ) );
  29      }
  30  
  31      /**
  32       * @ticket BP3680
  33       */
  34      public function test_should_ignore_multiple_word_html_comments_when_html_true() {
  35          $text = 'foo <!--one two three--> bar baz';
  36          $expected = 'foo <!--one two three--> bar';
  37          $this->assertSame( $expected, bp_create_excerpt( $text, 8, array(
  38              'ending' => '',
  39              'html' => true,
  40              'exact' => true,
  41          ) ) );
  42      }
  43  
  44      public function test_should_break_on_prior_word_boundary_when_exact_is_false() {
  45          $text = 'aaaaa aaaaaa';
  46          $expected = 'aaaaa';
  47          $this->assertSame( $expected, bp_create_excerpt( $text, 7, array(
  48              'exact' => false,
  49              'ending' => '',
  50          ) ) );
  51      }
  52  
  53      /**
  54       * @ticket BP6517
  55       */
  56      public function test_exact_false_should_properly_account_for_accented_characters() {
  57          $text = 'Toutes les connaissances que les hommes avaient mis sur Internet lui étaient accessible. Les grandes bibliothèques du monde entier n’avaient plus de secret pour lui. Il pouvait apprendre très vite, beaucoup plus vite que n’importe quel humain.
  58  Il avait appris toutes les connaissances du monde entier, visiter tout les pays. C’est lui qui avait fait en sorte qu’Internet se déploie ainsi.';
  59          $expected = 'Toutes les connaissances que les hommes avaient mis sur Internet lui étaient accessible. Les';
  60          $this->assertSame( $expected, bp_create_excerpt( $text, 98, array(
  61              'ending' => '',
  62              'exact' => false,
  63          ) ) );
  64      }
  65  
  66      /**
  67       * @ticket BP6254
  68       */
  69      public function test_should_trim_too_long_first_word_to_max_characters_even_when_exact_is_false() {
  70          $text = 'aaaaaaaaaaa';
  71          $expected = 'aaa';
  72          $this->assertSame( $expected, bp_create_excerpt( $text, 3, array(
  73              'exact' => false,
  74              'ending' => '',
  75          ) ) );
  76      }
  77  
  78      /**
  79       * @ticket BP6517
  80       */
  81      public function test_string_should_not_be_cut_mid_tag_when_exact_is_false() {
  82          $text = '<p><span>Foo</span> <a href="http://example.com">Bar</a> Baz.</p><p>Foo Bar Baz</p>';
  83          $actual = bp_create_excerpt( $text, 7, array(
  84              'html' => true,
  85              'ending' => '',
  86              'exact' => false,
  87          ) );
  88          $this->assertSame( '<p><span>Foo</span> <a href="http://example.com">Bar</a></p>', $actual );
  89      }
  90  }


Generated: Sat Apr 27 01:00:55 2024 Cross-referenced by PHPXref 0.7.1