aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php127
1 files changed, 127 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 3f3c60d0..3dd9273c 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -740,6 +740,133 @@ class ContentProxyTest extends TestCase
740 } 740 }
741 741
742 /** 742 /**
743 * Data provider for testWithChangedUrl.
744 *
745 * Arrays contain the following values:
746 * $entry_url
747 * $origin_url
748 * $content_url
749 * $expected_entry_url
750 * $expected_origin_url
751 * $expected_domain
752 */
753 public function dataForChangedUrl()
754 {
755 return [
756 'normal' => [
757 'http://0.0.0.0',
758 null,
759 'http://1.1.1.1',
760 'http://1.1.1.1',
761 'http://0.0.0.0',
762 '1.1.1.1',
763 ],
764 'origin already set' => [
765 'http://0.0.0.0',
766 'http://hello',
767 'http://1.1.1.1',
768 'http://1.1.1.1',
769 'http://hello',
770 '1.1.1.1',
771 ],
772 'trailing slash' => [
773 'https://example.com/hello-world',
774 null,
775 'https://example.com/hello-world/',
776 'https://example.com/hello-world/',
777 null,
778 'example.com',
779 ],
780 'query string in fetched content' => [
781 'https://example.org/hello',
782 null,
783 'https://example.org/hello?world=1',
784 'https://example.org/hello?world=1',
785 'https://example.org/hello',
786 'example.org',
787 ],
788 'fragment in fetched content' => [
789 'https://example.org/hello',
790 null,
791 'https://example.org/hello#world',
792 'https://example.org/hello',
793 null,
794 'example.org',
795 ],
796 'fragment and query string in fetched content' => [
797 'https://example.org/hello',
798 null,
799 'https://example.org/hello?foo#world',
800 'https://example.org/hello?foo#world',
801 'https://example.org/hello',
802 'example.org',
803 ],
804 'different path and query string in fetch content' => [
805 'https://example.org/hello',
806 null,
807 'https://example.org/world?foo',
808 'https://example.org/world?foo',
809 'https://example.org/hello',
810 'example.org',
811 ],
812 'feedproxy ignore list test' => [
813 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld',
814 null,
815 'https://example.org/hello-wallabag',
816 'https://example.org/hello-wallabag',
817 null,
818 'example.org',
819 ],
820 'feedproxy ignore list test with origin url already set' => [
821 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld',
822 'https://example.org/this-is-source',
823 'https://example.org/hello-wallabag',
824 'https://example.org/hello-wallabag',
825 'https://example.org/this-is-source',
826 'example.org',
827 ],
828 'lemonde ignore pattern test' => [
829 'http://www.lemonde.fr/tiny/url',
830 null,
831 'http://example.com/hello-world',
832 'http://example.com/hello-world',
833 null,
834 'example.com',
835 ],
836 ];
837 }
838
839 /**
840 * @dataProvider dataForChangedUrl
841 */
842 public function testWithChangedUrl($entry_url, $origin_url, $content_url, $expected_entry_url, $expected_origin_url, $expected_domain)
843 {
844 $tagger = $this->getTaggerMock();
845 $tagger->expects($this->once())
846 ->method('tag');
847
848 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true);
849 $entry = new Entry(new User());
850 $entry->setOriginUrl($origin_url);
851 $proxy->updateEntry(
852 $entry,
853 $entry_url,
854 [
855 'html' => false,
856 'title' => '',
857 'url' => $content_url,
858 'content_type' => '',
859 'language' => '',
860 ],
861 true
862 );
863
864 $this->assertSame($expected_entry_url, $entry->getUrl());
865 $this->assertSame($expected_domain, $entry->getDomainName());
866 $this->assertSame($expected_origin_url, $entry->getOriginUrl());
867 }
868
869 /**
743 * https://stackoverflow.com/a/18506801. 870 * https://stackoverflow.com/a/18506801.
744 * 871 *
745 * @param $string 872 * @param $string