Skip to content

Commit fca2904

Browse files
committed
Don't check imported urls while testing
1 parent ed108b3 commit fca2904

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

includes/class-import.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private static function get_feed_from_opml_node( $friend ) {
3434
$username = preg_replace( '/^https?:\/\//', '', $username );
3535
}
3636
if ( ! $username ) {
37-
$username = (string) $friend['xmlUrl'];
37+
$username = (string) $xml_url;
3838
$username = preg_replace( '/^https?:\/\//', '', $username );
3939
}
4040

@@ -67,6 +67,10 @@ private static function get_feed_from_opml_node( $friend ) {
6767
);
6868

6969
if ( ! $feed instanceof User_Feed ) {
70+
if ( is_wp_error( $feed ) && apply_filters( 'friends_debug', false ) ) {
71+
wp_trigger_error( __FUNCTION__, $feed->get_error_message() );
72+
73+
}
7074
return null;
7175
}
7276

includes/class-user.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public function save_feeds( $feeds = array() ) {
388388
$errors = new \WP_Error();
389389
foreach ( $feeds as $feed_url => $options ) {
390390
if ( ! is_string( $feed_url ) || ! Friends::check_url( $feed_url ) ) {
391-
$errors->add( 'invalid-url', 'An invalid URL was provided' );
391+
$errors->add( 'invalid-url', 'An invalid URL was provided', $feed_url );
392392
unset( $feeds[ $feed_url ] );
393393
continue;
394394
}
@@ -406,7 +406,8 @@ public function save_feeds( $feeds = array() ) {
406406

407407
$all_urls = array();
408408
foreach ( wp_get_object_terms( $this->get_object_id(), User_Feed::TAXONOMY ) as $term ) {
409-
$all_urls[ $term->name ] = $term->term_id;
409+
$url = str_replace( '&', '&', $term->name );
410+
$all_urls[ $url ] = $term->term_id;
410411
}
411412

412413
$user_feeds = wp_set_object_terms( $this->get_object_id(), array_keys( array_merge( $all_urls, $feeds ) ), User_Feed::TAXONOMY );
@@ -415,7 +416,8 @@ public function save_feeds( $feeds = array() ) {
415416
}
416417

417418
foreach ( wp_get_object_terms( $this->get_object_id(), User_Feed::TAXONOMY ) as $term ) {
418-
$all_urls[ $term->name ] = $term->term_id;
419+
$url = str_replace( '&', '&', $term->name );
420+
$all_urls[ $url ] = $term->term_id;
419421
}
420422

421423
foreach ( $feeds as $url => $feed_options ) {

tests/test-feed.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ public function test_podcast() {
680680
}
681681

682682
public function test_import_feedland_opml() {
683+
add_filter( 'friends_pre_check_url', '__return_true' );
684+
683685
$opml = file_get_contents( __DIR__ . '/data/feedland.opml' );
684686
$feeds = Import::opml( $opml );
685687
$users_created = count( $feeds );
@@ -692,14 +694,16 @@ public function test_import_feedland_opml() {
692694
}
693695

694696
public function test_import_friends_opml() {
697+
add_filter( 'friends_pre_check_url', '__return_true' );
698+
695699
$opml = file_get_contents( __DIR__ . '/data/friends.opml' );
696700
$feeds = Import::opml( $opml );
697701
$users_created = count( $feeds );
698702
$feeds_imported = 0;
699703
foreach ( $feeds as $user => $user_feeds ) {
700704
$feeds_imported += count( $user_feeds );
701705
}
702-
$this->assertEquals( 19, $users_created );
703-
$this->assertEquals( 20, $feeds_imported );
706+
$this->assertEquals( 22, $users_created );
707+
$this->assertEquals( 24, $feeds_imported );
704708
}
705709
}

0 commit comments

Comments
 (0)