|
4 | 4 |
|
5 | 5 | namespace PhpStringHelpers\Tests; |
6 | 6 |
|
| 7 | +use PhpParser\Node\Expr\BinaryOp\BooleanOr; |
7 | 8 | use PHPUnit\Framework\TestCase; |
8 | 9 | use PhpStringHelpers\exceptions\UrlIsNotValidException; |
9 | | -use PhpStringHelpers\utility\StrUtility as strHelpersTest; |
| 10 | +use PhpStringHelpers\Facade\StrUtility as strHelpersTest; |
10 | 11 | use PhpStringHelpers\exceptions\FileDoesNotExistsException; |
11 | 12 | use PhpStringHelpers\exceptions\LanguageFileIsNotArrayException; |
12 | 13 |
|
@@ -837,4 +838,112 @@ public function testIsSlugReturnTrueIfGivenStringIsASlug() |
837 | 838 | $slug = strHelpersTest::is_slug('132Foo-12bar-3432az'); |
838 | 839 | $this->assertTrue($slug); |
839 | 840 | } |
| 841 | + |
| 842 | + public function testIsIpV4CanReturnBooleanValue() |
| 843 | + { |
| 844 | + $ip = strHelpersTest::is_ipv4('127.0.0.1'); |
| 845 | + $this->assertIsBool($ip); |
| 846 | + } |
| 847 | + |
| 848 | + public function testIsIpV4CanReturnFalseIfGivenIp4IsNotValid() |
| 849 | + { |
| 850 | + $ip = strHelpersTest::is_ipv4('127.0.0.256'); |
| 851 | + $this->assertFalse($ip); |
| 852 | + } |
| 853 | + |
| 854 | + public function testIsIpV4CanReturnTrueIfGivenIp4IsValid() |
| 855 | + { |
| 856 | + $ip = strHelpersTest::is_ipv4('127.0.0.255'); |
| 857 | + $this->assertTrue($ip); |
| 858 | + } |
| 859 | + |
| 860 | + public function testIsIpV4CanReturnFalseIfGivenIpParamIsEmpty() |
| 861 | + { |
| 862 | + $ip = strHelpersTest::is_ipv4(''); |
| 863 | + $this->assertFalse($ip); |
| 864 | + } |
| 865 | + |
| 866 | + public function testIsIpV4CanReturnFalseIfGivenIpParamIsNotString() |
| 867 | + { |
| 868 | + $ip = strHelpersTest::is_ipv4('foo bar'); |
| 869 | + $this->assertFalse($ip); |
| 870 | + } |
| 871 | + |
| 872 | + public function testIsIpV6CanReturnBooleanValue() |
| 873 | + { |
| 874 | + $ip = strHelpersTest::is_ipv6('2001:0db8:0000:0000:0000:ff00:0042:8329'); |
| 875 | + $this->assertIsBool($ip); |
| 876 | + } |
| 877 | + |
| 878 | + public function testIsIpV6CanReturnFalseIfGivenIp6IsNotValid() |
| 879 | + { |
| 880 | + $ip = strHelpersTest::is_ipv6('127.0.0.1'); |
| 881 | + $this->assertFalse($ip); |
| 882 | + } |
| 883 | + |
| 884 | + public function testIsIpV6CanReturnTrueIfGivenIp6IsValid() |
| 885 | + { |
| 886 | + $ip = strHelpersTest::is_ipv6('2001:0db8:0000:0000:0000:ff00:0042:8329'); |
| 887 | + $this->assertTrue($ip); |
| 888 | + } |
| 889 | + |
| 890 | + public function testIsIpV6CanReturnFalseIfGivenIpParamIsEmpty() |
| 891 | + { |
| 892 | + $ip = strHelpersTest::is_ipv6(''); |
| 893 | + $this->assertFalse($ip); |
| 894 | + } |
| 895 | + |
| 896 | + public function testIsIpV6CanReturnFalseIfGivenIpParamIsNotString() |
| 897 | + { |
| 898 | + $ip = strHelpersTest::is_ipv6('foo bar baz'); |
| 899 | + $this->assertFalse($ip); |
| 900 | + } |
| 901 | + |
| 902 | + public function testAfterCanReturnStringValue() |
| 903 | + { |
| 904 | + $string = strHelpersTest::after('foo bar baz', 'bar'); |
| 905 | + $this->assertIsString($string); |
| 906 | + } |
| 907 | + |
| 908 | + public function testAfterCanReturnStringParamIfStringParamIsEmpty() |
| 909 | + { |
| 910 | + $string = strHelpersTest::after('', 'foo'); |
| 911 | + $this->assertEquals('', $string); |
| 912 | + } |
| 913 | + |
| 914 | + public function testAfterCanReturnStringParamIfSearchIsEmpty() |
| 915 | + { |
| 916 | + $string = strHelpersTest::after('foo bar baz', ''); |
| 917 | + $this->assertEquals('foo bar baz', $string); |
| 918 | + } |
| 919 | + |
| 920 | + public function testAfterCanRemoveTheWordsBeforeTheSearchParam() |
| 921 | + { |
| 922 | + $string = strHelpersTest::after('foo bar baz', 'bar'); |
| 923 | + $this->assertEquals('baz', $string); |
| 924 | + } |
| 925 | + |
| 926 | + public function testBeforeCanReturnStringValue() |
| 927 | + { |
| 928 | + $string = strHelpersTest::before('foo bar baz', 'bar'); |
| 929 | + $this->assertIsString($string); |
| 930 | + } |
| 931 | + |
| 932 | + public function testBeforeCanReturnStringParamIfStringParamIsEmpty() |
| 933 | + { |
| 934 | + $string = strHelpersTest::before('', 'foo'); |
| 935 | + $this->assertEquals('', $string); |
| 936 | + } |
| 937 | + |
| 938 | + public function testBeforeCanReturnStringParamIfSearchIsEmpty() |
| 939 | + { |
| 940 | + $string = strHelpersTest::before('foo bar baz', ''); |
| 941 | + $this->assertEquals('foo bar baz', $string); |
| 942 | + } |
| 943 | + |
| 944 | + public function testBeforeCanRemoveTheWordsAfterTheSearchParam() |
| 945 | + { |
| 946 | + $string = strHelpersTest::before('foo bar baz', 'foo'); |
| 947 | + $this->assertEquals('', $string); |
| 948 | + } |
840 | 949 | } |
0 commit comments