Changeset 42343 for trunk/tests/phpunit/tests/functions/getArchives.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/getArchives.php
r38398 r42343 17 17 18 18 $this->month_url = get_month_link( date( 'Y' ), date( 'm' ) ); 19 $this->year_url = get_year_link( date( 'Y' ) );19 $this->year_url = get_year_link( date( 'Y' ) ); 20 20 } 21 21 22 22 public static function wpSetUpBeforeClass( $factory ) { 23 self::$post_ids = $factory->post->create_many( 8, array( 'post_type' => 'post', 'post_author' => '1' ) ); 23 self::$post_ids = $factory->post->create_many( 24 8, array( 25 'post_type' => 'post', 26 'post_author' => '1', 27 ) 28 ); 24 29 } 25 30 26 31 function test_wp_get_archives_default() { 27 $expected['default'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . "</a></li>";32 $expected['default'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></li>'; 28 33 $this->assertEquals( $expected['default'], trim( wp_get_archives( array( 'echo' => false ) ) ) ); 29 34 } 30 35 31 36 function test_wp_get_archives_type() { 32 $expected['type'] = "<li><a href='" . $this->year_url . "'>" . date( 'Y' ) . "</a></li>"; 33 $this->assertEquals( $expected['type'], trim( wp_get_archives( array( 'echo' => false, 'type' => 'yearly' ) ) ) ); 37 $expected['type'] = "<li><a href='" . $this->year_url . "'>" . date( 'Y' ) . '</a></li>'; 38 $this->assertEquals( 39 $expected['type'], trim( 40 wp_get_archives( 41 array( 42 'echo' => false, 43 'type' => 'yearly', 44 ) 45 ) 46 ) 47 ); 34 48 } 35 49 … … 56 70 <li><a href='$link5'>$title5</a></li> 57 71 EOF; 58 $this->assertEquals( $expected['limit'], trim( wp_get_archives( array( 'echo' => false, 'type' => 'postbypost', 'limit' => 5 ) ) ) ); 72 $this->assertEquals( 73 $expected['limit'], trim( 74 wp_get_archives( 75 array( 76 'echo' => false, 77 'type' => 'postbypost', 78 'limit' => 5, 79 ) 80 ) 81 ) 82 ); 59 83 } 60 84 61 85 function test_wp_get_archives_format() { 62 86 $expected['format'] = "<option value='" . $this->month_url . "'> " . date( 'F Y' ) . ' </option>'; 63 $this->assertEquals( $expected['format'], trim( wp_get_archives( array( 'echo' => false, 'format' => 'option' ) ) ) ); 87 $this->assertEquals( 88 $expected['format'], trim( 89 wp_get_archives( 90 array( 91 'echo' => false, 92 'format' => 'option', 93 ) 94 ) 95 ) 96 ); 64 97 } 65 98 66 99 function test_wp_get_archives_before_and_after() { 67 100 $expected['before_and_after'] = "<div><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></div>'; 68 $this->assertEquals( $expected['before_and_after'], trim( wp_get_archives( array( 'echo' => false, 'format' => 'custom', 'before' => '<div>', 'after' => '</div>' ) ) ) ); 101 $this->assertEquals( 102 $expected['before_and_after'], trim( 103 wp_get_archives( 104 array( 105 'echo' => false, 106 'format' => 'custom', 107 'before' => '<div>', 108 'after' => '</div>', 109 ) 110 ) 111 ) 112 ); 69 113 } 70 114 71 115 function test_wp_get_archives_show_post_count() { 72 $expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . "</a> (8)</li>"; 73 $this->assertEquals( $expected['show_post_count'], trim( wp_get_archives( array( 'echo' => false, 'show_post_count' => 1 ) ) ) ); 116 $expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a> (8)</li>'; 117 $this->assertEquals( 118 $expected['show_post_count'], trim( 119 wp_get_archives( 120 array( 121 'echo' => false, 122 'show_post_count' => 1, 123 ) 124 ) 125 ) 126 ); 74 127 } 75 128 … … 83 136 84 137 function test_wp_get_archives_order() { 85 self::factory()->post->create( array( 'post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42' ) ); 86 87 $date_full = date( 'F Y' ); 88 $oct_url = get_month_link( 2012, 10 ); 138 self::factory()->post->create( 139 array( 140 'post_type' => 'post', 141 'post_author' => '1', 142 'post_date' => '2012-10-23 19:34:42', 143 ) 144 ); 145 146 $date_full = date( 'F Y' ); 147 $oct_url = get_month_link( 2012, 10 ); 89 148 $expected['order_asc'] = <<<EOF 90 149 <li><a href='{$oct_url}'>October 2012</a></li> 91 150 <li><a href='{$this->month_url}'>$date_full</a></li> 92 151 EOF; 93 $this->assertEquals( $expected['order_asc'], trim( wp_get_archives( array( 'echo' => false, 'order' => 'ASC' ) ) ) ); 152 $this->assertEquals( 153 $expected['order_asc'], trim( 154 wp_get_archives( 155 array( 156 'echo' => false, 157 'order' => 'ASC', 158 ) 159 ) 160 ) 161 ); 94 162 95 163 $expected['order_desc'] = <<<EOF … … 97 165 <li><a href='{$oct_url}'>October 2012</a></li> 98 166 EOF; 99 $this->assertEquals( $expected['order_desc'], trim( wp_get_archives( array( 'echo' => false, 'order' => 'DESC' ) ) ) ); 167 $this->assertEquals( 168 $expected['order_desc'], trim( 169 wp_get_archives( 170 array( 171 'echo' => false, 172 'order' => 'DESC', 173 ) 174 ) 175 ) 176 ); 100 177 } 101 178 … … 106 183 register_post_type( 'taco', array( 'public' => true ) ); 107 184 108 self::factory()->post->create( array( 109 'post_type' => 'taco', 110 'post_author' => '1', 111 'post_date' => '2014-10-23 19:34:42' 112 ) ); 113 114 $oct_url = esc_url( add_query_arg( 'post_type', 'taco', get_month_link( 2014, 10 ) ) ); 185 self::factory()->post->create( 186 array( 187 'post_type' => 'taco', 188 'post_author' => '1', 189 'post_date' => '2014-10-23 19:34:42', 190 ) 191 ); 192 193 $oct_url = esc_url( add_query_arg( 'post_type', 'taco', get_month_link( 2014, 10 ) ) ); 115 194 $expected = "<li><a href='{$oct_url}'>October 2014</a></li>"; 116 $archives = wp_get_archives( array( 'echo' => false, 'post_type' => 'taco' ) ); 195 $archives = wp_get_archives( 196 array( 197 'echo' => false, 198 'post_type' => 'taco', 199 ) 200 ); 117 201 $this->assertEquals( $expected, trim( $archives ) ); 118 202 }
Note: See TracChangeset
for help on using the changeset viewer.