├── tests ├── files │ ├── html │ │ ├── getbody-2.html │ │ ├── getbody-2-expected.html │ │ ├── totext-6-expected.txt │ │ ├── totext-6.html │ │ ├── totext-3-expected.txt │ │ ├── totext-3.html │ │ ├── getbody-1-expected.html │ │ ├── totext-5-expected.txt │ │ ├── getbody-1.html │ │ ├── removejavascriptevents-expected.html │ │ ├── removedangerous-expected.html │ │ ├── removeattributes-1-expected.html │ │ ├── fromtext-1.txt │ │ ├── removeattributes-2-expected.html │ │ ├── removejavascriptevents.html │ │ ├── removeattributes-1.html │ │ ├── removeattributes-2.html │ │ ├── totext-2-expected.txt │ │ ├── removetags-1-expected.html │ │ ├── removedangerous.html │ │ ├── fromtext-1-expected.html │ │ ├── totext-1-expected.txt │ │ ├── totext-7-expected.txt │ │ ├── totext-5.html │ │ ├── totext-2.html │ │ ├── removetags-2-expected.html │ │ ├── repair-expected.html │ │ ├── removetags-1.html │ │ ├── removetags-2.html │ │ ├── totext-1.html │ │ └── repair.html │ ├── rpc │ │ ├── abs-expected.json │ │ ├── diff-expected.json │ │ ├── pow2-expected.json │ │ ├── sum-expected.json │ │ ├── max-expected.json │ │ ├── pow2.json │ │ ├── parse-error.json │ │ ├── abs.json │ │ ├── sum.json │ │ ├── max.json │ │ ├── min.json │ │ ├── diff.json │ │ ├── parse-error-expected.json │ │ ├── sum-short-expected.json │ │ ├── sum-short.json │ │ ├── min-expected.json │ │ ├── expected.log │ │ ├── abs-expected.xml │ │ ├── sum-expected.xml │ │ ├── diff-expected.xml │ │ ├── max-expected.xml │ │ ├── pow2-expected.xml │ │ ├── sum-short-expected.xml │ │ ├── pow2.xml │ │ ├── abs.xml │ │ ├── testPow2.php │ │ ├── sum-short.xml │ │ ├── sum.xml │ │ ├── diff.xml │ │ ├── max.xml │ │ ├── min.xml │ │ ├── parse-error.xml │ │ ├── min-expected.xml │ │ ├── parse-error-expected.xml │ │ ├── TestMathWithCall.php │ │ ├── TestMathWithCallStatic.php │ │ └── TestMath.php │ ├── mail │ │ ├── logo.gif │ │ ├── star.gif │ │ └── sender-undisclosed-recipients.eml │ ├── charset │ │ ├── cp1250.txt │ │ └── iso-8859-2.txt │ ├── css │ │ ├── convertstyle-6.html │ │ ├── convertstyle-6-expected.html │ │ ├── convertstyle-8.html │ │ ├── convertstyle-9.html │ │ ├── convertstyle-7.html │ │ ├── convertstyle-7-expected.html │ │ ├── convertstyle-2.html │ │ ├── convertstyle-8-expected.html │ │ ├── convertstyle-2-expected.html │ │ ├── convertstyle-10.html │ │ ├── convertstyle-9-expected.html │ │ ├── convertstyle-3.html │ │ ├── convertstyle-3-expected.html │ │ └── convertstyle-10-expected.html │ ├── time │ │ └── cs_CZ │ │ │ └── LC_MESSAGES │ │ │ └── messages.mo │ ├── input │ │ ├── Filter.php │ │ └── Validator.php │ ├── xmlreader │ │ ├── text.xml │ │ └── content.xml │ └── spl │ │ ├── Foo2.php │ │ ├── Foo.php │ │ └── Foo3.php ├── bootstrap.php └── Jyxo │ ├── Gettext │ └── ParserTest.php │ ├── Mail │ └── Email │ │ ├── HeaderTest.php │ │ ├── BodyTest.php │ │ ├── Attachment │ │ ├── FileAttachmentTest.php │ │ ├── InlineFileAttachmentTest.php │ │ ├── StringAttachmentTest.php │ │ └── InlineStringAttachmentTest.php │ │ └── AddressTest.php │ ├── Rpc │ ├── Xml │ │ └── ServerTest.php │ └── Json │ │ └── ServerTest.php │ ├── Time │ ├── ComposerExceptionTest.php │ └── UtilTest.php │ ├── Spl │ ├── FilterIteratorTest.php │ └── BaseObjectTest.php │ ├── Beholder │ ├── TestCase │ │ ├── DefaultTest.php │ │ ├── PhpExtensionTest.php │ │ ├── ImapTest.php │ │ ├── MemcachedTest.php │ │ └── SmtpTest.php │ └── TestCaseTest.php │ ├── Input │ └── Chain │ │ └── ConditionalTest.php │ └── TimerTest.php ├── .gitignore ├── Jyxo ├── Beholder │ ├── Output │ │ ├── NoOutput.php │ │ ├── Output.php │ │ └── JsonOutput.php │ ├── TestCase.php │ ├── TestCase │ │ ├── PhpExtension.php │ │ └── FileSystem.php │ └── Result │ │ └── TestSuiteResult.php ├── Input │ ├── Exception.php │ ├── Filter │ │ ├── Exception.php │ │ ├── LowerCase.php │ │ ├── SanitizeUrl.php │ │ ├── ToInt.php │ │ ├── ExplodeName.php │ │ ├── Phone.php │ │ ├── AbstractFilter.php │ │ └── Trim.php │ ├── Validator │ │ ├── Exception.php │ │ ├── NotEmpty.php │ │ ├── ErrorMessage.php │ │ ├── IsArray.php │ │ ├── IsZipCode.php │ │ ├── IsEmail.php │ │ ├── IsNumeric.php │ │ ├── IsInt.php │ │ ├── IsIpV4.php │ │ ├── AbstractValidator.php │ │ ├── IsDate.php │ │ ├── InArray.php │ │ ├── IsPhone.php │ │ ├── IsDateTime.php │ │ ├── IsCompanyId.php │ │ ├── Equals.php │ │ ├── LessThan.php │ │ ├── IsUrl.php │ │ ├── Regex.php │ │ ├── IsIpV6.php │ │ ├── StringLengthLessThan.php │ │ ├── StringLengthGreaterThan.php │ │ ├── IsTaxId.php │ │ └── IsBirthNumber.php │ ├── FilterInterface.php │ ├── ValidatorInterface.php │ ├── Filter.php │ ├── Validator.php │ └── Chain │ │ └── Conditional.php ├── Rpc │ ├── Exception.php │ ├── Json │ │ └── Exception.php │ └── Xml │ │ ├── Exception.php │ │ ├── Server.php │ │ └── Client.php ├── Svn │ └── Exception.php ├── Webdav │ ├── Exception.php │ ├── FileNotExistException.php │ ├── FileNotCopiedException.php │ ├── FileNotCreatedException.php │ ├── FileNotDeletedException.php │ ├── FileNotRenamedException.php │ ├── DirectoryNotCreatedException.php │ ├── DirectoryNotDeletedException.php │ ├── LoggerInterface.php │ ├── FileLogger.php │ └── MonologLogger.php ├── Shell │ └── Exception.php ├── Mail │ ├── Parser │ │ ├── Exception.php │ │ ├── EmailNotExistException.php │ │ ├── BodyNotDecodedException.php │ │ ├── PartNotExistException.php │ │ └── DefaultPartIdNotExistException.php │ ├── Sender │ │ ├── Exception.php │ │ ├── SmtpException.php │ │ ├── CreateException.php │ │ ├── RecipientUnknownException.php │ │ └── Result.php │ └── Email │ │ ├── Attachment │ │ ├── FileAttachment.php │ │ ├── InlineFileAttachment.php │ │ ├── StringAttachment.php │ │ └── InlineStringAttachment.php │ │ ├── Header.php │ │ ├── Address.php │ │ └── Body.php ├── Gettext │ └── Parser │ │ ├── Exception.php │ │ └── Header.php ├── Spl │ ├── ArrayCopy.php │ └── FilterIterator.php ├── Exception.php ├── Timer.php └── Time │ └── ComposerException.php ├── composer.json ├── phpunit.xml.dist └── license.txt /tests/files/html/getbody-2.html: -------------------------------------------------------------------------------- 1 |

Text

-------------------------------------------------------------------------------- /tests/files/html/getbody-2-expected.html: -------------------------------------------------------------------------------- 1 |

Text

-------------------------------------------------------------------------------- /tests/files/rpc/abs-expected.json: -------------------------------------------------------------------------------- 1 | {"result":10,"id":42} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /composer.lock 3 | /temp 4 | /vendor 5 | -------------------------------------------------------------------------------- /tests/files/rpc/diff-expected.json: -------------------------------------------------------------------------------- 1 | {"result":10,"id":"jyxoid"} -------------------------------------------------------------------------------- /tests/files/rpc/pow2-expected.json: -------------------------------------------------------------------------------- 1 | {"result":100,"id":"cet21"} -------------------------------------------------------------------------------- /tests/files/rpc/sum-expected.json: -------------------------------------------------------------------------------- 1 | {"result":3,"id":"123456"} -------------------------------------------------------------------------------- /tests/files/html/totext-6-expected.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | TOM & JERRY -------------------------------------------------------------------------------- /tests/files/rpc/max-expected.json: -------------------------------------------------------------------------------- 1 | {"result":100,"id":"typewriter"} -------------------------------------------------------------------------------- /tests/files/rpc/pow2.json: -------------------------------------------------------------------------------- 1 | {"method":"testPow2","params":[10],"id":"cet21"} -------------------------------------------------------------------------------- /tests/files/rpc/parse-error.json: -------------------------------------------------------------------------------- 1 | {"method":"TestMath::min","params":[1,100,10]} -------------------------------------------------------------------------------- /tests/files/html/totext-6.html: -------------------------------------------------------------------------------- 1 |

<Nadpis>

2 |

Tom & Jerry

-------------------------------------------------------------------------------- /tests/files/rpc/abs.json: -------------------------------------------------------------------------------- 1 | {"method":"TestMathWithCall::abs","params":[-10],"id":42} -------------------------------------------------------------------------------- /tests/files/rpc/sum.json: -------------------------------------------------------------------------------- 1 | {"method":"TestMath::sum","params":[1,2],"id":"123456"} -------------------------------------------------------------------------------- /tests/files/rpc/max.json: -------------------------------------------------------------------------------- 1 | {"method":"TestMath::max","params":[1,100,10],"id":"typewriter"} -------------------------------------------------------------------------------- /tests/files/rpc/min.json: -------------------------------------------------------------------------------- 1 | {"method":"TestMath::min","params":[1,100,10],"id":"jyxolibs"} -------------------------------------------------------------------------------- /tests/files/mail/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jyxo/php/HEAD/tests/files/mail/logo.gif -------------------------------------------------------------------------------- /tests/files/mail/star.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jyxo/php/HEAD/tests/files/mail/star.gif -------------------------------------------------------------------------------- /tests/files/rpc/diff.json: -------------------------------------------------------------------------------- 1 | {"method":"TestMathWithCallStatic::diff","params":[20,10],"id":"jyxoid"} -------------------------------------------------------------------------------- /tests/files/rpc/parse-error-expected.json: -------------------------------------------------------------------------------- 1 | {"error":{"message":"Parse error.","code":10},"id":""} -------------------------------------------------------------------------------- /tests/files/rpc/sum-short-expected.json: -------------------------------------------------------------------------------- 1 | {"result":3,"id":"a2a13eed69d3bdf21b9bfbbe7ee0ff8271d2788c"} -------------------------------------------------------------------------------- /tests/files/charset/cp1250.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jyxo/php/HEAD/tests/files/charset/cp1250.txt -------------------------------------------------------------------------------- /tests/files/charset/iso-8859-2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jyxo/php/HEAD/tests/files/charset/iso-8859-2.txt -------------------------------------------------------------------------------- /tests/files/rpc/sum-short.json: -------------------------------------------------------------------------------- 1 | {"method":"sum","params":[1,2],"id":"a2a13eed69d3bdf21b9bfbbe7ee0ff8271d2788c"} -------------------------------------------------------------------------------- /tests/files/css/convertstyle-6.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jyxo/php/HEAD/tests/files/css/convertstyle-6.html -------------------------------------------------------------------------------- /tests/files/rpc/min-expected.json: -------------------------------------------------------------------------------- 1 | {"error":{"message":"Server error. Method not found.","code":-32601},"id":"jyxolibs"} -------------------------------------------------------------------------------- /tests/files/css/convertstyle-6-expected.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jyxo/php/HEAD/tests/files/css/convertstyle-6-expected.html -------------------------------------------------------------------------------- /tests/files/rpc/expected.log: -------------------------------------------------------------------------------- 1 | [2009-11-15 19:09:24] 2 | Method: TestMath::sum 3 | Param 0: 1 4 | Param 1: 2 5 | Result: 5 6 | -------------------------------------------------------------------------------- /tests/files/time/cs_CZ/LC_MESSAGES/messages.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jyxo/php/HEAD/tests/files/time/cs_CZ/LC_MESSAGES/messages.mo -------------------------------------------------------------------------------- /tests/files/html/totext-3-expected.txt: -------------------------------------------------------------------------------- 1 | > one one one 2 | > 3 | >> second 4 | >> 5 | >>> third 6 | >>> 7 | >> second 8 | >> 9 | > one 10 | > -------------------------------------------------------------------------------- /tests/files/html/totext-3.html: -------------------------------------------------------------------------------- 1 |
2 | one 3 | one 4 | one 5 |
second 6 |
third
7 | second 8 |
9 | one 10 |
11 | -------------------------------------------------------------------------------- /tests/files/rpc/abs-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/files/rpc/sum-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 3 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/files/html/getbody-1-expected.html: -------------------------------------------------------------------------------- 1 |
2 | 		Pre
3 | 		Pre
4 | 	
5 | 6 | 7 |

8 | First 9 |

-------------------------------------------------------------------------------- /tests/files/rpc/diff-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/files/rpc/max-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 100 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/files/rpc/pow2-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 100 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/files/rpc/sum-short-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 3 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/files/rpc/pow2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | testPow2 4 | 5 | 6 | 7 | 10 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/files/rpc/abs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestMathWithCall::abs 4 | 5 | 6 | 7 | -10 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/files/rpc/testPow2.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | 12 |

13 | First 14 |

15 | 16 | -------------------------------------------------------------------------------- /tests/files/rpc/sum-short.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | sum 4 | 5 | 6 | 7 | 1 8 | 9 | 10 | 11 | 12 | 2 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/files/input/Filter.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestMath::sum 4 | 5 | 6 | 7 | 1 8 | 9 | 10 | 11 | 12 | 2 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 |

10 | Link 11 | Button 12 |

13 | 14 | 15 | -------------------------------------------------------------------------------- /tests/files/rpc/diff.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestMathWithCallStatic::diff 4 | 5 | 6 | 7 | 20 8 | 9 | 10 | 11 | 12 | 10 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-9.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 |

10 |

First
paragraph
11 |
Second
paragraph
12 |
Third
paragraph
13 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/files/html/removejavascriptevents-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | Link 12 | 13 | 14 |

15 | First 16 |

17 | 18 | -------------------------------------------------------------------------------- /tests/files/html/removedangerous-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | Alert 12 | 13 | 14 | 15 | Alert 16 | 17 | 18 | 19 | 20 |

21 | First 22 |

23 | 24 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-7-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/files/xmlreader/text.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | word 5 | two words 6 | three simple words 7 | 8 | four words on several lines 9 | 10 | fifth test with tags 11 | sixth test with tags and inner tags 12 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

H1

6 |

7 | Link 8 | 9 | 10 | 11 |

12 |

H2

13 |

Text text text

14 | 15 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-8-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 |

10 | Link 11 | Button 12 |

13 | 14 | 15 | -------------------------------------------------------------------------------- /tests/files/rpc/max.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestMath::max 4 | 5 | 6 | 7 | 1 8 | 9 | 10 | 11 | 12 | 100 13 | 14 | 15 | 16 | 17 | 10 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/files/rpc/min.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestMath::min 4 | 5 | 6 | 7 | 1 8 | 9 | 10 | 11 | 12 | 100 13 | 14 | 15 | 16 | 17 | 10 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/files/rpc/parse-error.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestMath::min 4 | 5 | 6 | 7 | 1 8 | 9 | 10 | 11 | 12 | 100 13 | 14 | 15 | 16 | 17 | 10 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/files/html/removeattributes-1-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | Link 13 | 14 | 15 |

16 | First 17 |

18 | 19 | -------------------------------------------------------------------------------- /tests/files/input/Validator.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

H1

6 |

7 | Link 8 | 9 | 10 | 11 |

12 |

H2

13 |

Text text text

14 | 15 | -------------------------------------------------------------------------------- /tests/files/html/fromtext-1.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | odsazeno 8 | odsazeno 9 | odsazeno 10 | 11 | 12 | 13 | tabulátor 14 | tabulátor 15 | tabulátor 16 | 17 | 18 | 19 | email@domain.tld 20 | 21 | 22 | 23 | http://domain.tld 24 | 25 | 26 | 27 | >> Text 28 | >> Text 29 | >> 30 | 31 | 32 | 33 | >> Text 34 | >> Text 35 | >> 36 | > Text 37 | > Text 38 | > 39 | > Text 40 | > 41 | 42 | -------------------------------------------------------------------------------- /tests/files/html/removeattributes-2-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | Link 13 | 14 | 15 |

16 | First 17 |

18 | 19 | -------------------------------------------------------------------------------- /tests/files/mail/sender-undisclosed-recipients.eml: -------------------------------------------------------------------------------- 1 | Date: Fri, 02 Oct 09 15:06:50 +0200 2 | Return-Path: 3 | From: "Blog.cz" 4 | Subject: Test 5 | To: undisclosed-recipients:; 6 | Bcc: Test Test 7 | Message-ID: 8 | MIME-Version: 1.0 9 | Content-Type: text/plain; charset="iso-8859-2" 10 | Content-Transfer-Encoding: quoted-printable 11 | 12 | Test 13 | -------------------------------------------------------------------------------- /tests/files/html/removejavascriptevents.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | Link 13 | 14 | 15 |

16 | First 17 |

18 | 19 | -------------------------------------------------------------------------------- /tests/files/html/removeattributes-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | Link 13 | 14 | 15 |

16 | First 17 |

18 | 19 | -------------------------------------------------------------------------------- /tests/files/html/removeattributes-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | Link 13 | 14 | 15 |

16 | First 17 |

18 | 19 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-10.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 |
1
11 |
2
12 |
3 13 |
31
14 | XX 15 |
32
16 | XX 17 |
33 18 |
331
19 |
332
20 |
333
21 |
22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-9-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 |

10 |

First
paragraph
11 |
Second
paragraph
12 |
Third
paragraph
13 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/files/html/totext-2-expected.txt: -------------------------------------------------------------------------------- 1 | * item 1 2 | * item 2 3 | 4 | 1. one 5 | 2. two 6 | 7 | o item 1 8 | o item 2 9 | 10 | 1. one 11 | 2. two 12 | 13 | + item 1 14 | + item 2 15 | 16 | # item 1 17 | # item 2 18 | 19 | * item 1 20 | * item 2 21 | * item 3 22 | 23 | # item 3 24 | 25 | + item 3 26 | 27 | 3. three 28 | 29 | o item 3 30 | 31 | 3. three 32 | 33 | * item 3 34 | 35 | 1. one 36 | 2. two 37 | 3. three -------------------------------------------------------------------------------- /tests/files/rpc/min-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | faultString 8 | 9 | server error. method not found. 10 | 11 | TestMath::min 12 | 13 | 14 | 15 | faultCode 16 | 17 | -32601 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tests/files/rpc/parse-error-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | faultString 8 | 9 | parse error. not well formed. 10 | 11 | error occurred at line 21, column 10, byte index 287 12 | 13 | 14 | 15 | faultCode 16 | 17 | -32700 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tests/files/html/removetags-1-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | 12 | 13 |

14 | First 15 |

16 |

17 | Second 18 | Link 19 |

20 |
21 |
    22 |
  • List
  • 23 |
  • List
  • 24 |
25 |

26 | Third
27 |

28 | 29 | -------------------------------------------------------------------------------- /tests/files/html/removedangerous.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
 7 | 		Pre
 8 | 		Pre
 9 | 	
10 | 11 | Alert 12 | 13 | 14 | 15 | Alert 16 | 17 | 18 | 19 | 20 |

21 | First 22 |

23 | 24 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 14 | 15 | 16 |

H1

17 |

18 | Link 19 | 20 | 21 | 22 |

23 |

H2

24 |

Text text text

25 | 26 | -------------------------------------------------------------------------------- /tests/files/css/convertstyle-3-expected.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 14 | 15 | 16 |

H1

17 |

18 | Link 19 | 20 | 21 | 22 |

23 |

H2

24 |

Text text text

25 | 26 | -------------------------------------------------------------------------------- /tests/files/html/fromtext-1-expected.html: -------------------------------------------------------------------------------- 1 |

<email@domain.tld>

  odsazeno
  odsazeno
  odsazeno

    tabulátor
    tabulátor
    tabulátor

email@domain.tld

http://domain.tld

Text
Text

Text
Text

Text
Text

Text

-------------------------------------------------------------------------------- /Jyxo/Beholder/Output/NoOutput.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 |
1
11 |
2
12 |
3 13 |
31
14 | XX 15 |
32
16 | XX 17 |
33 18 |
331
19 |
332
20 |
333
21 |
22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/files/xmlreader/content.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | word 5 | two words 6 | threesimple words 7 | 8 | fourwordsonseverallines 9 | 10 | fifth test without tags 11 | 12 | tags in seventh test]]> 13 | eigth test with tags and attributes 14 | ninth test with tags and attributes and inner tags 15 | -------------------------------------------------------------------------------- /Jyxo/Input/Exception.php: -------------------------------------------------------------------------------- 1 | data = $data; 24 | } 25 | 26 | /** 27 | * Returns an iterator instance. 28 | * 29 | * @return ArrayIterator 30 | */ 31 | public function getIterator(): ArrayIterator 32 | { 33 | return new ArrayIterator($this->data); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Jyxo/Rpc/Exception.php: -------------------------------------------------------------------------------- 1 | 1 35 | 1 < 2 36 | 2 > 1 37 | 1 < 2 38 | 39 | ampersand & ampersand & ampersand 40 | 41 | (c) Copyright 42 | (c) Copyright 43 | 44 | (tm) Trade mark 45 | 46 | (R) Registration 47 | 48 | hi-fi 49 | hi-fi 50 | 51 | span 52 | em 53 | 54 | 55 | jyxo.cz 56 | Jyxo 57 | Jyxo 58 | Jyxo 59 | Jyxo 60 | Jyxo 61 | Jyxo 62 | Jyxo 63 | džykso.cz 64 | 65 | tabulátor 66 | tabulátor 67 | 68 | odsazení 69 | odsazení 70 | 71 | Text Text Text -------------------------------------------------------------------------------- /tests/files/html/totext-7-expected.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 200 KREDITOV NA LETNÚ DOVOLENKU 4 | 5 | Hezký den! 6 | 7 | Všimli sme si, že odmeny vo výške 2% z vašich mesačných nákupov, ktoré dostávate späť, sú v priemere iba 18 kreditov každý mesiac. Áno, tak málo. Toto zistenie nás priviedlo k tomu, že tieto odmeny zatiaľ rušíme. Ale za to vám vymyslíme niečo oveľa lepšie! 8 | 9 | 200 kreditov na letný pobyt 10 | 11 | Neustále sa vás snažíme inšpirovať. Preto dávame zbohom kreditovým omrvinkám a namiesto toho môžete hneď teraz získať 200 kreditov na cestovateľské zážitky na Slovensku. 12 | 13 | Pripíšte si 200 kreditov na cestovanie -------------------------------------------------------------------------------- /tests/files/html/totext-5.html: -------------------------------------------------------------------------------- 1 |
  • 2 |

    ahojky takže pořád mám pozastaveno,pze jedu na letní tábor dnes.no jako moc se tam netěšim ae zase budu mít klid od svý sestry.Úsměv

    3 |

4 |
  • RTNHMÚsměv

5 |
  • 6 |

    až se sem dostamu zase neco přidám!<3

    7 |
  • mějte se tu krásně!!!a pls sb si mě nevymazávelje
-------------------------------------------------------------------------------- /Jyxo/Input/FilterInterface.php: -------------------------------------------------------------------------------- 1 | 2 |
  • item 1
  • 3 |
  • item 2 4 |
      5 |
    1. one
    2. 6 |
    3. two 7 |
        8 |
      • item 1
      • 9 |
      • item 2 10 |
          11 |
        1. one
        2. 12 |
        3. two 13 |
            14 |
          • item 1
          • 15 |
          • item 2 16 |
              17 |
            • item 1
            • 18 |
            • item 2 19 |
                20 |
              • item 1
              • 21 |
              • item 2
              • 22 |
              • item 3
              • 23 |
              24 |
            • 25 |
            • item 3
            • 26 |
            27 |
          • 28 |
          • item 3
          • 29 |
          30 |
        4. 31 |
        5. three
        6. 32 |
        33 |
      • 34 |
      • item 3
      • 35 |
      36 |
    4. 37 |
    5. three
    6. 38 |
    39 |
  • 40 |
  • item 3
  • 41 | 42 |
      43 |
    1. one
    2. 44 |
    3. two
    4. 45 |
    5. three
    6. 46 |
    -------------------------------------------------------------------------------- /Jyxo/Input/ValidatorInterface.php: -------------------------------------------------------------------------------- 1 | result = $result; 34 | } 35 | 36 | public function getResult(): TestSuiteResult 37 | { 38 | return $this->result; 39 | } 40 | 41 | abstract public function __toString(): string; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /tests/Jyxo/Gettext/ParserTest.php: -------------------------------------------------------------------------------- 1 | assertCount(300, $po); 33 | 34 | foreach ($po as $item) { 35 | $this->assertInstanceOf(Item::class, $item); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Jyxo/Input/Filter/SanitizeUrl.php: -------------------------------------------------------------------------------- 1 | x; 33 | } 34 | 35 | /** 36 | * Sets the firstvariable value. 37 | * 38 | * @param int $x New value 39 | */ 40 | public function setX(int $x): void 41 | { 42 | $this->x = $x; 43 | } 44 | 45 | /** 46 | * Returns the second variable value. 47 | * 48 | * @return bool 49 | */ 50 | public function isY(): bool 51 | { 52 | return $this->y; 53 | } 54 | 55 | /** 56 | * Sets the second variable value. 57 | * 58 | * @param bool $y New value 59 | */ 60 | public function setY(bool $y): void 61 | { 62 | $this->y = $y; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Jyxo/Exception.php: -------------------------------------------------------------------------------- 1 | getPrevious(); 35 | 36 | while ($previous !== null) { 37 | $stack[] = $previous; 38 | $previous = $previous->getPrevious(); 39 | } 40 | 41 | return $stack; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jyxo/php", 3 | "type": "library", 4 | "description": "Jyxo PHP Library", 5 | "keywords": ["php", "jyxo", "rpc", "gettext", "webdav", "beholder", "svn", "shell"], 6 | "homepage": "http://jyxo.github.com/php/", 7 | "license": ["BSD-3-Clause"], 8 | "authors": [ 9 | { "name" : "Jaroslav Hanslík" }, 10 | { "name" : "Ondřej Nešpor" } 11 | ], 12 | "require": { 13 | "php": "^7.1 || ^8.0" 14 | }, 15 | "require-dev": { 16 | "php-parallel-lint/php-parallel-lint": "1.2.0", 17 | "phpunit/phpunit": "^9.5.0", 18 | "slevomat/coding-standard": "6.4.1" 19 | }, 20 | "suggest": { 21 | "guzzlehttp/guzzle": "To use Jyxo\\Webdav client", 22 | "ext-curl": "To use Jyxo\\Rpc client/server or Jyxo\\Webdav client", 23 | "ext-json": "To use Jyxo\\Rpc\\Json client/server or Jyxo\\FirePHP logger", 24 | "ext-xmlrpc": "To use Jyxo\\Rpc\\Xml client/server", 25 | "ext-imap": "To use Jyxo\\Mail\\Parser" 26 | }, 27 | "autoload": { 28 | "psr-4": { "Jyxo\\": ["Jyxo/"] } 29 | }, 30 | "config": { 31 | "bin-dir": "bin", 32 | "optimize-autoloader": true, 33 | "classmap-authoritative": true 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsEmail.php: -------------------------------------------------------------------------------- 1 | assertEquals($name, $header->getName()); 40 | $this->assertEquals($value, $header->getValue()); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsNumeric.php: -------------------------------------------------------------------------------- 1 | {$array[0]} = $array[1]; 48 | } 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /tests/Jyxo/Rpc/Xml/ServerTest.php: -------------------------------------------------------------------------------- 1 | base = $base; 43 | } 44 | 45 | /** 46 | * Filters a value. 47 | * 48 | * @param mixed $in Input value 49 | * @return mixed 50 | */ 51 | protected function filterValue($in) 52 | { 53 | return intval($in, $this->base); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Jyxo/Input/Filter/ExplodeName.php: -------------------------------------------------------------------------------- 1 | $firstname, 45 | 'lastname' => $lastname, 46 | ]; 47 | 48 | return $in; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | ./tests/ 21 | ./tests/Jyxo/Time/TimeTest.php 22 | 23 | 24 | 25 | 26 | 27 | ./Jyxo/ 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/AbstractValidator.php: -------------------------------------------------------------------------------- 1 | newInstanceArgs(array_slice(func_get_args(), 1)); 41 | 42 | return $validator->isValid($value); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Jyxo/Input/Filter/Phone.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
     7 | 		Pre
     8 | 		Pre
     9 | 	
    10 | 11 | 12 | 13 |
    14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
    42 | 43 |
    44 | 45 | 46 | 47 | 50 | 51 | 54 | 55 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/InArray.php: -------------------------------------------------------------------------------- 1 | allowed = $allowed; 43 | } 44 | 45 | /** 46 | * Validates a value. 47 | * 48 | * @param mixed $value Input value 49 | * @return bool 50 | */ 51 | public function isValid($value): bool 52 | { 53 | return in_array($value, $this->allowed, true); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Jyxo/Beholder/TestCase.php: -------------------------------------------------------------------------------- 1 | description = $description; 49 | } 50 | 51 | /** 52 | * Returns the description. 53 | * 54 | * @return string 55 | */ 56 | public function getDescription(): string 57 | { 58 | return $this->description; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /tests/Jyxo/Time/ComposerExceptionTest.php: -------------------------------------------------------------------------------- 1 | getConstants() as $code) { 39 | $exception = new ComposerException('Test', $code); 40 | $this->assertEquals($code, $exception->getCode()); 41 | } 42 | 43 | // Non-existent code 44 | $exception = new ComposerException('Test', 99); 45 | $this->assertEquals(ComposerException::UNKNOWN, $exception->getCode()); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Jyxo/Mail/Email/Attachment/FileAttachment.php: -------------------------------------------------------------------------------- 1 | setContent(file_get_contents($path)); 46 | $this->setName($name); 47 | $this->setMimeType($mimeType); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Jyxo/Webdav/FileLogger.php: -------------------------------------------------------------------------------- 1 | fileName = $fileName; 46 | } 47 | 48 | /** 49 | * Logs the given message. 50 | * 51 | * @param string $message Message to be logged 52 | */ 53 | public function log(string $message): void 54 | { 55 | file_put_contents($this->fileName, sprintf("[%s]: %s\n", date('Y-m-d H:i:s'), $message), FILE_APPEND); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsPhone.php: -------------------------------------------------------------------------------- 1 | data = $data; 31 | } 32 | 33 | /** 34 | * Returns the current item value. 35 | * 36 | * @return mixed 37 | */ 38 | public function current() 39 | { 40 | return $this->data[$this->pointer] ?? null; 41 | } 42 | 43 | /** 44 | * Advances the internal pointer. 45 | */ 46 | public function next(): void 47 | { 48 | $this->pointer++; 49 | } 50 | 51 | /** 52 | * Sets the internal pointer to 0. 53 | */ 54 | public function rewind(): void 55 | { 56 | $this->pointer = 0; 57 | } 58 | 59 | /** 60 | * Returns if the current pointer position is valid. 61 | * 62 | * @return bool 63 | */ 64 | public function valid(): bool 65 | { 66 | return isset($this->data[$this->pointer]); 67 | } 68 | 69 | /** 70 | * Returns the current pointer value. 71 | * 72 | * @return int 73 | */ 74 | public function key(): int 75 | { 76 | return $this->pointer; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /Jyxo/Webdav/MonologLogger.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 51 | $this->level = $level; 52 | } 53 | 54 | /** 55 | * Logs the given message. 56 | * 57 | * @param string $message Message to be logged 58 | */ 59 | public function log(string $message): void 60 | { 61 | $this->logger->addRecord($this->level, $message); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Jyxo/Mail/Sender/RecipientUnknownException.php: -------------------------------------------------------------------------------- 1 | list = $list; 45 | } 46 | 47 | /** 48 | * Returns the list of non-existent addresses. 49 | * 50 | * @return array 51 | */ 52 | public function getList(): array 53 | { 54 | return $this->list; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /tests/Jyxo/Spl/FilterIteratorTest.php: -------------------------------------------------------------------------------- 1 | 0, 45 | 2 => 2, 46 | 4 => 4, 47 | 6 => 6, 48 | 8 => 8, 49 | 10 => 10, 50 | ]; 51 | 52 | $results = []; 53 | 54 | foreach ($iterator as $key => $value) { 55 | $results[$key] = $value; 56 | } 57 | 58 | $this->assertSame($expected, $results); 59 | $this->assertSame($expected, $iterator->toArray()); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /tests/Jyxo/Beholder/TestCase/DefaultTest.php: -------------------------------------------------------------------------------- 1 | autoloadList = spl_autoload_functions(); 44 | 45 | foreach ($this->autoloadList as $function) { 46 | spl_autoload_unregister($function); 47 | } 48 | } 49 | 50 | /** 51 | * Turns autoloading on. 52 | */ 53 | protected function enableAutoload(): void 54 | { 55 | foreach ($this->autoloadList as $function) { 56 | spl_autoload_register($function); 57 | } 58 | 59 | $this->autoloadList = []; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /tests/Jyxo/Mail/Email/BodyTest.php: -------------------------------------------------------------------------------- 1 | assertEquals($html, $body->getMain()); 42 | $this->assertEquals($text, $body->getAlternative()); 43 | $this->assertTrue($body->isHtml()); 44 | 45 | // Only HTML 46 | $body = new Body($html); 47 | $this->assertEquals($html, $body->getMain()); 48 | $this->assertTrue($body->isHtml()); 49 | 50 | // Only plaintext 51 | $body = new Body($text); 52 | $this->assertEquals($text, $body->getMain()); 53 | $this->assertFalse($body->isHtml()); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Jyxo/Input/Filter.php: -------------------------------------------------------------------------------- 1 | getFilterByName($method, $params)); 49 | 50 | return $filter->filter($value); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsDateTime.php: -------------------------------------------------------------------------------- 1 | 23) { 51 | return false; 52 | } 53 | 54 | if ($minute < 0 || $minute > 59) { 55 | return false; 56 | } 57 | 58 | return $second >= 0 && $second <= 59; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2014, Jyxo, s.r.o. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of Jyxo, s.r.o. nor the names of its 15 | contributors may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /tests/Jyxo/Beholder/TestCase/PhpExtensionTest.php: -------------------------------------------------------------------------------- 1 | run(); 37 | $this->assertEquals(Result::FAILURE, $result->getStatus()); 38 | $this->assertEquals('Missing runkit, parsekit', $result->getDescription()); 39 | } 40 | 41 | /** 42 | * Tests all requested extension present. 43 | */ 44 | public function testAvailable(): void 45 | { 46 | $test = new PhpExtension('Extensions', ['pcre', 'spl', 'reflection']); 47 | $result = $test->run(); 48 | $this->assertEquals(Result::SUCCESS, $result->getStatus()); 49 | $this->assertEquals('OK', $result->getDescription()); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Jyxo/Input/Filter/AbstractFilter.php: -------------------------------------------------------------------------------- 1 | filterValue($in); 52 | } 53 | 54 | /** 55 | * Filters a value. 56 | * 57 | * @param mixed $value Input value 58 | * @return mixed 59 | */ 60 | public static function filtrate($value) 61 | { 62 | $filter = new static(); 63 | 64 | return $filter->filter($value); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /tests/Jyxo/Beholder/TestCaseTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(self::DESCRIPTION, $this->testcase->getDescription()); 47 | } 48 | 49 | /** 50 | * Prepares the testing environment. 51 | */ 52 | protected function setUp(): void 53 | { 54 | $this->testcase = $this->getMockForAbstractClass(\Jyxo\Beholder\TestCase::class, [self::DESCRIPTION]); 55 | } 56 | 57 | /** 58 | * Cleans up the testing environment. 59 | */ 60 | protected function tearDown(): void 61 | { 62 | $this->testcase = null; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsCompanyId.php: -------------------------------------------------------------------------------- 1 | assertEquals(file_get_contents($path), $attachment->getContent()); 42 | $this->assertEquals($name, $attachment->getName()); 43 | $this->assertEquals($mimeType, $attachment->getMimeType()); 44 | $this->assertEquals(Attachment::DISPOSITION_ATTACHMENT, $attachment->getDisposition()); 45 | $this->assertFalse($attachment->isInline()); 46 | $this->assertEquals('', $attachment->getCid()); 47 | $this->assertEquals('', $attachment->getEncoding()); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /tests/files/html/repair-expected.html: -------------------------------------------------------------------------------- 1 |

     

    <jyxo@jyxo.com>

                    Pre
    Pre

    First

    Second Link


    Third

    • List
    • List
      Alert

    No frames

    -------------------------------------------------------------------------------- /Jyxo/Input/Validator/Equals.php: -------------------------------------------------------------------------------- 1 | setExpected($expected); 41 | } 42 | 43 | /** 44 | * Sets the expected value. 45 | * 46 | * @param mixed $expected Expected value 47 | * @return Equals 48 | */ 49 | public function setExpected($expected): self 50 | { 51 | $this->expected = $expected; 52 | 53 | return $this; 54 | } 55 | 56 | /** 57 | * Returns the expected value. 58 | * 59 | * @return mixed 60 | */ 61 | public function getExpected() 62 | { 63 | return $this->expected; 64 | } 65 | 66 | /** 67 | * Validates a value. 68 | * 69 | * @param mixed $value Input value 70 | * @return bool 71 | */ 72 | public function isValid($value): bool 73 | { 74 | return $value === $this->expected; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /Jyxo/Mail/Email/Attachment/InlineFileAttachment.php: -------------------------------------------------------------------------------- 1 | setContent(file_get_contents($path)); 47 | $this->setName($name); 48 | $this->setCid($cid); 49 | $this->setMimeType($mimeType); 50 | } 51 | 52 | /** 53 | * Sets Id. 54 | * 55 | * @param string $cid Id 56 | * @return FileAttachment 57 | */ 58 | public function setCid(string $cid): self 59 | { 60 | $this->cid = $cid; 61 | 62 | return $this; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /tests/Jyxo/Mail/Email/Attachment/InlineFileAttachmentTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(file_get_contents($path), $attachment->getContent()); 43 | $this->assertEquals($name, $attachment->getName()); 44 | $this->assertEquals($mimeType, $attachment->getMimeType()); 45 | $this->assertEquals(Attachment::DISPOSITION_INLINE, $attachment->getDisposition()); 46 | $this->assertTrue($attachment->isInline()); 47 | $this->assertEquals($cid, $attachment->getCid()); 48 | $this->assertEquals('', $attachment->getEncoding()); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/LessThan.php: -------------------------------------------------------------------------------- 1 | setMax($max); 43 | } 44 | 45 | /** 46 | * Sets the maximum value. 47 | * 48 | * @param int $max New maximum value 49 | * @return LessThan 50 | */ 51 | public function setMax(int $max): self 52 | { 53 | $this->max = $max; 54 | 55 | return $this; 56 | } 57 | 58 | /** 59 | * Returns the maximum value. 60 | * 61 | * @return int 62 | */ 63 | public function getMax(): int 64 | { 65 | return $this->max; 66 | } 67 | 68 | /** 69 | * Validates a value. 70 | * 71 | * @param mixed $value Input value 72 | * @return bool 73 | */ 74 | public function isValid($value): bool 75 | { 76 | return (int) $value < $this->getMax(); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator.php: -------------------------------------------------------------------------------- 1 | getValidatorByName($method, $params) 51 | ); 52 | } catch (Throwable $e) { 53 | $validator = $factory->getValidatorByName($method, $params); 54 | } 55 | 56 | return $validator->isValid($value); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /tests/Jyxo/Spl/BaseObjectTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('Foo', $foo->getClass()); 42 | 43 | // Setting parameter values 44 | $foo->x = 1; 45 | $foo->y = true; 46 | 47 | // Setting a non-existent parameter value 48 | $foo->z = 'test'; 49 | 50 | // Fetching parameter values 51 | $this->assertSame(1, $foo->x); 52 | $this->assertTrue($foo->y); 53 | 54 | // Fetching value of a non-existent parameter 55 | $this->assertNull($foo->z); 56 | 57 | // Testing parameter existence 58 | $this->assertTrue(isset($foo->x)); 59 | $this->assertTrue(isset($foo->y)); 60 | $this->assertFalse(isset($foo->z)); 61 | 62 | // Testing toArray conversion 63 | $array = ['x' => 1, 'y' => true]; 64 | $this->assertEquals($array, $foo->toArray()); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsUrl.php: -------------------------------------------------------------------------------- 1 | callback = $callback; 48 | } 49 | 50 | /** 51 | * Decides if an item is valid by calling a callback. 52 | * 53 | * @return bool 54 | */ 55 | public function accept(): bool 56 | { 57 | $callback = $this->callback; 58 | 59 | return $callback($this->current()); 60 | } 61 | 62 | /** 63 | * Returns all filtered data as an array. 64 | * 65 | * @return array 66 | */ 67 | public function toArray(): array 68 | { 69 | return iterator_to_array($this); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /tests/files/html/removetags-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
     7 | 		Pre
     8 | 		Pre
     9 | 	
    10 | 11 | 12 | 13 |

    14 | First 15 |

    16 |

    17 | Second 18 | Link 19 |

    20 |
    21 |
      22 |
    • List
    • 23 |
    • List
    • 24 |
    25 | 26 | 27 | 28 | 29 | 30 | <p>No frames</p> 31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
    55 | 56 |
    57 | 58 | 59 | 64 | 65 | 68 | 69 | 72 |

    73 | Third
    74 |

    75 | 76 | -------------------------------------------------------------------------------- /tests/files/html/removetags-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Test 4 | 5 | 6 |
     7 | 		Pre
     8 | 		Pre
     9 | 	
    10 | 11 | 12 | 13 |

    14 | First 15 |

    16 |

    17 | Second 18 | Link 19 |

    20 |
    21 |
      22 |
    • List
    • 23 |
    • List
    • 24 |
    25 | 26 | 27 | 28 | 29 | 30 | <p>No frames</p> 31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
    55 | 56 |
    57 | 58 | 59 | 64 | 65 | 68 | 69 | 72 |

    73 | Third
    74 |

    75 | 76 | -------------------------------------------------------------------------------- /Jyxo/Beholder/TestCase/PhpExtension.php: -------------------------------------------------------------------------------- 1 | extensionList = $extensionList; 50 | } 51 | 52 | /** 53 | * Performs the test. 54 | * 55 | * @return Result 56 | */ 57 | public function run(): Result 58 | { 59 | // Check 60 | $missing = []; 61 | 62 | foreach ($this->extensionList as $extension) { 63 | if (!extension_loaded($extension)) { 64 | $missing[] = $extension; 65 | } 66 | } 67 | 68 | // Some extensions are missing 69 | if (!empty($missing)) { 70 | return new Result(Result::FAILURE, sprintf('Missing %s', implode(', ', $missing))); 71 | } 72 | 73 | // OK 74 | return new Result(Result::SUCCESS); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/Regex.php: -------------------------------------------------------------------------------- 1 | setPattern($pattern); 43 | } 44 | 45 | /** 46 | * Sets the validation regular expression. 47 | * 48 | * @param string $pattern Regular expression 49 | * @return Regex 50 | */ 51 | public function setPattern(string $pattern): self 52 | { 53 | if (empty($pattern)) { 54 | throw new Exception('Pattern could not be empty'); 55 | } 56 | 57 | $this->pattern = $pattern; 58 | 59 | return $this; 60 | } 61 | 62 | /** 63 | * Returns the validation regular expression. 64 | * 65 | * @return string 66 | */ 67 | public function getPattern(): string 68 | { 69 | return $this->pattern; 70 | } 71 | 72 | /** 73 | * Validates a value. 74 | * 75 | * @param mixed $value Input value 76 | * @return bool 77 | */ 78 | public function isValid($value): bool 79 | { 80 | return preg_match($this->getPattern(), (string) $value) === 1; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsIpV6.php: -------------------------------------------------------------------------------- 1 | assertFalse(Util::isWorkDay(new Time($day))); 52 | } 53 | 54 | foreach ($working as $day) { 55 | $this->assertTrue(Util::isWorkDay(new Time($day))); 56 | } 57 | } 58 | 59 | /** 60 | * Tests the nextMonth() method. 61 | */ 62 | public function testNextMonth(): void 63 | { 64 | $dates = [ 65 | '2010-01-01' => '2010-02-01', 66 | '2010-01-31' => '2010-02-28', 67 | '2012-01-31' => '2012-02-29', 68 | '2010-12-31' => '2011-01-31', 69 | '2010-08-31' => '2010-09-30', 70 | ]; 71 | 72 | foreach ($dates as $current => $expected) { 73 | $time = new Time($current); 74 | $next = Util::nextMonth($time); 75 | 76 | $this->assertEquals($expected . ' 00:00:00', $next->format('Y-m-d H:i:s')); 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /Jyxo/Beholder/Result/TestSuiteResult.php: -------------------------------------------------------------------------------- 1 | project = $project; 49 | $this->allSucceeded = $allSucceeded; 50 | $this->testsData = $testsData; 51 | $this->includeFilter = $includeFilter; 52 | $this->excludeFilter = $excludeFilter; 53 | } 54 | 55 | public function getProject(): string 56 | { 57 | return $this->project; 58 | } 59 | 60 | public function hasAllSucceeded(): bool 61 | { 62 | return $this->allSucceeded; 63 | } 64 | 65 | /** 66 | * @return array 67 | */ 68 | public function getTestsData(): array 69 | { 70 | return $this->testsData; 71 | } 72 | 73 | public function getIncludeFilter(): string 74 | { 75 | return $this->includeFilter; 76 | } 77 | 78 | public function getExcludeFilter(): string 79 | { 80 | return $this->excludeFilter; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/StringLengthLessThan.php: -------------------------------------------------------------------------------- 1 | setMax($max); 44 | } 45 | 46 | /** 47 | * Sets the maximal string length. 48 | * 49 | * @param int $max Maximal string length 50 | * @return StringLengthLessThan 51 | */ 52 | public function setMax(int $max): self 53 | { 54 | if ($max <= 0) { 55 | throw new InvalidArgumentException('Length of string must be greater than zero.'); 56 | } 57 | 58 | $this->max = $max; 59 | 60 | return $this; 61 | } 62 | 63 | /** 64 | * Returns the maximal string length. 65 | * 66 | * @return int 67 | */ 68 | public function getMax(): int 69 | { 70 | return $this->max; 71 | } 72 | 73 | /** 74 | * Validates a value. 75 | * 76 | * @param mixed $value Input value 77 | * @return bool 78 | */ 79 | public function isValid($value): bool 80 | { 81 | return mb_strlen((string) $value, 'utf-8') < $this->getMax(); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/StringLengthGreaterThan.php: -------------------------------------------------------------------------------- 1 | setMin($min); 44 | } 45 | 46 | /** 47 | * Sets the minimal string length. 48 | * 49 | * @param int $min Minimal string length 50 | * @return StringLengthGreaterThan 51 | */ 52 | public function setMin(int $min): self 53 | { 54 | if ($min < 0) { 55 | throw new InvalidArgumentException('Length of string must be greater than zero.'); 56 | } 57 | 58 | $this->min = $min; 59 | 60 | return $this; 61 | } 62 | 63 | /** 64 | * Returns the minimal string length. 65 | * 66 | * @return int 67 | */ 68 | public function getMin(): int 69 | { 70 | return $this->min; 71 | } 72 | 73 | /** 74 | * Validates a value. 75 | * 76 | * @param mixed $value Input value 77 | * @return bool 78 | */ 79 | public function isValid($value): bool 80 | { 81 | return mb_strlen((string) $value, 'utf-8') > $this->getMin(); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /tests/Jyxo/Beholder/TestCase/ImapTest.php: -------------------------------------------------------------------------------- 1 | run(); 42 | $this->assertEquals(Result::FAILURE, $result->getStatus()); 43 | $this->assertEquals(sprintf('Connection error @%s:143', $host), $result->getDescription()); 44 | } 45 | 46 | /** 47 | * Tests working connection. 48 | */ 49 | public function testAllOk(): void 50 | { 51 | // Skip the test if no IMAP connection is defined 52 | if (empty($GLOBALS['imap']) || (!preg_match('~^([^:]+):([^@]+)@([^:]+):(\\d+)$~', $GLOBALS['imap'], $matches))) { 53 | $this->markTestSkipped('Imap not set'); 54 | } 55 | 56 | [$user, $password, $host, $port] = array_slice($matches, 1); 57 | 58 | $test = new Imap('Imap', $host, $user, $password, $port, false); 59 | $result = $test->run(); 60 | $this->assertEquals(Result::SUCCESS, $result->getStatus()); 61 | $this->assertEquals(sprintf('%s@%s:%s', $user, $host, $port), $result->getDescription()); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Jyxo/Beholder/Output/JsonOutput.php: -------------------------------------------------------------------------------- 1 | result->getTestsData() as $data) { 38 | $tests[] = [ 39 | 'order' => $data['order'], 40 | 'duration' => sprintf('%.6f s', $data['duration']), 41 | 'ident' => $data['ident'], 42 | 'result' => $data['result']->getStatusMessage(), 43 | 'test_description' => $data['test']->getDescription(), 44 | 'result_description' => $data['result']->getDescription(), 45 | ]; 46 | } 47 | 48 | $data = [ 49 | 'included' => $this->result->getIncludeFilter(), 50 | 'excluded' => $this->result->getExcludeFilter(), 51 | 'tests' => $tests, 52 | 'urls' => [ 53 | 'text' => '?' . Executor::PARAM_INCLUDE . '=' . $this->result->getIncludeFilter() 54 | . '&' . Executor::PARAM_EXCLUDE . '=' . $this->result->getExcludeFilter() 55 | . '&' . Executor::PARAM_OUTPUT . '=' . Executor::OUTPUT_TEXT, 56 | 'html' => '?' . Executor::PARAM_INCLUDE . '=' . $this->result->getIncludeFilter() 57 | . '&' . Executor::PARAM_EXCLUDE . '=' . $this->result->getExcludeFilter() 58 | . '&' . Executor::PARAM_OUTPUT . '=' . Executor::OUTPUT_HTML, 59 | ], 60 | ]; 61 | 62 | return json_encode($data); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /tests/Jyxo/Mail/Email/AddressTest.php: -------------------------------------------------------------------------------- 1 | assertEquals($email, $address->getEmail()); 44 | $this->assertEquals($name, $address->getName()); 45 | 46 | // Only email given 47 | $address = new Address($email); 48 | $this->assertEquals($email, $address->getEmail()); 49 | $this->assertEquals('', $address->getName()); 50 | 51 | // It is necessary to trim whitespace 52 | $address = new Address(' ' . $email, $name . ' '); 53 | $this->assertEquals($email, $address->getEmail()); 54 | $this->assertEquals($name, $address->getName()); 55 | 56 | // Invalid email 57 | try { 58 | $address = new Address('žlutý kůň@jyxo.com', $name); 59 | $this->fail(sprintf('Expected exception %s.', InvalidArgumentException::class)); 60 | } catch (AssertionFailedError $e) { 61 | throw $e; 62 | } catch (Throwable $e) { 63 | // Correctly thrown exception 64 | $this->assertInstanceOf(InvalidArgumentException::class, $e); 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Jyxo/Mail/Email/Attachment/StringAttachment.php: -------------------------------------------------------------------------------- 1 | setContent($content); 49 | $this->setName($name); 50 | $this->setMimeType($mimeType); 51 | $this->setEncoding($encoding); 52 | } 53 | 54 | /** 55 | * Sets contents encoding. 56 | * If none is set, assume no encoding is used. 57 | * 58 | * @param string $encoding Encoding name 59 | * @return StringAttachment 60 | */ 61 | public function setEncoding(string $encoding): self 62 | { 63 | if (!empty($encoding) && (!Encoding::isCompatible($encoding))) { 64 | throw new InvalidArgumentException(sprintf('Incompatible encoding %s', $encoding)); 65 | } 66 | 67 | $this->encoding = $encoding; 68 | 69 | return $this; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /Jyxo/Mail/Email/Header.php: -------------------------------------------------------------------------------- 1 | setName($name); 51 | $this->setValue($value); 52 | } 53 | 54 | /** 55 | * Returns header name. 56 | * 57 | * @return string 58 | */ 59 | public function getName(): string 60 | { 61 | return $this->name; 62 | } 63 | 64 | /** 65 | * Sets header name. 66 | * 67 | * @param string $name Name 68 | * @return Header 69 | */ 70 | public function setName(string $name): self 71 | { 72 | $this->name = $name; 73 | 74 | return $this; 75 | } 76 | 77 | /** 78 | * Returns value. 79 | * 80 | * @return string 81 | */ 82 | public function getValue(): string 83 | { 84 | return $this->value; 85 | } 86 | 87 | /** 88 | * Sets value. 89 | * 90 | * @param string $value Value 91 | * @return Header 92 | */ 93 | public function setValue(string $value): self 94 | { 95 | $this->value = $value; 96 | 97 | return $this; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /Jyxo/Timer.php: -------------------------------------------------------------------------------- 1 | true for any value 39 | $validator = new Conditional(); 40 | 41 | foreach (['example', 42, [], new stdClass(), 1.23, true, false] as $value) { 42 | $this->assertTrue($validator->isValid($value)); 43 | } 44 | } 45 | 46 | /** 47 | * Tests for conditional validation (is executed only if the condition is fulfilled) 48 | */ 49 | public function testCondition(): void 50 | { 51 | static $value = 42; 52 | $validator = new Conditional(new IsInt()); 53 | $validator->addValidator(new LessThan($value)); 54 | $good = [ 55 | $value - 1, 56 | (int) ($value / 2), 57 | sqrt($value), 58 | 'example', 59 | false, 60 | true, 61 | ]; 62 | $bad = [ 63 | $value * 2, 64 | (string) ($value * 2), 65 | (float) ($value * 2), 66 | ]; 67 | 68 | foreach ($good as $value) { 69 | $this->assertTrue( 70 | $validator->isValid($value), 71 | sprintf('Test of value %s should be true but is false.', $value) 72 | ); 73 | } 74 | 75 | foreach ($bad as $value) { 76 | $this->assertFalse( 77 | $validator->isValid($value), 78 | sprintf('Test of value %s should be false but is true.', $value) 79 | ); 80 | } 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /tests/files/html/totext-1.html: -------------------------------------------------------------------------------- 1 |
      2 | 	pre
      3 | 	pre
      4 | 
    5 | 6 |

    h1…

    7 |

    h2

    8 |

    h3

    9 |

    h4

    10 |
    h5
    11 |
    h6
    12 | 13 |
    14 | div
    15 | div 16 |
    17 | 18 |

    19 | paragraph
    20 | paragraph 21 |

    22 | 23 |

    24 | strong 25 |

    26 | 27 |
    28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
    head1head2
    body1body2
    41 | 42 |

    43 | "quotes"
    44 | “quotes”
    45 |

    46 | 47 |

    48 | 'apostrophe'
    49 |

    50 | 51 |

    52 | 2 > 1
    53 | 1 < 2
    54 | 2 > 1
    55 | 1 < 2
    56 |

    57 | 58 |

    59 | ampersand & ampersand & ampersand
    60 |

    61 | 62 |

    63 | © Copyright
    64 | © Copyright
    65 |

    66 | 67 |

    68 | ™ Trade mark
    69 |

    70 | 71 |

    72 | ® Registration
    73 |

    74 | 75 |

    76 | hi—fi
    77 | hi–fi
    78 |

    79 | 80 |

    81 | span
    82 | em
    83 |
    84 |

    85 | 86 |

    87 | jyxo.czjyxo.czjyxo.cz
    88 | jyxo.cz
    89 | Jyxo
    90 | Jyxo
    91 | Jyxo
    92 | Jyxo
    93 | Jyxo
    94 | Jyxo
    95 | Jyxo
    96 | džykso.cz
    97 |

    98 | 99 |

    100 |     tabulátor
    101 |     tabulátor
    102 |

    103 | 104 |

    105 |   odsazení
    106 |   odsazení
    107 |

    108 | 109 | 110 | 111 | 112 | 113 |

    114 | Text Text Text
    115 |

    -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsTaxId.php: -------------------------------------------------------------------------------- 1 | strict = (bool) $strict; 46 | } 47 | 48 | /** 49 | * Validates a value. 50 | * 51 | * @param mixed $value Input value 52 | * @return bool 53 | */ 54 | public function isValid($value): bool 55 | { 56 | // Removes spaces 57 | $taxId = preg_replace('~\\s+~', '', (string) $value); 58 | 59 | // Group tax ID format since 1st January 2009 60 | if (preg_match('~^CZ699\\d{6}$~', $taxId, $matches)) { 61 | return true; 62 | } 63 | 64 | $sub = ''; 65 | 66 | // New Tax ID format since 1st May 2004 67 | if (preg_match('~^CZ(\\d{8,10})$~', $taxId, $matches)) { 68 | $sub = $matches[1]; 69 | } 70 | 71 | if (!empty($sub)) { 72 | // Strict checking off - allows the so called "own numbers" 73 | if (!$this->strict) { 74 | return true; 75 | } 76 | 77 | // Checks if it is a valid IČ 78 | if (IsCompanyId::validate($sub)) { 79 | return true; 80 | } 81 | 82 | // Checks if it is a valid birth number 83 | if (IsBirthNumber::validate($sub)) { 84 | return true; 85 | } 86 | } 87 | 88 | return false; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /tests/files/html/repair.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 11 | 12 | 13 | 14 |

     

    15 | 16 | <jyxo@jyxo.com> 17 | 18 |
    19 | 		Pre
    20 | 		Pre
    21 | 	
    22 | 23 | 24 | 25 | 26 |

    27 | First 28 |

    29 |

    30 | Second 31 | Link 32 |

    33 |
    34 |

    35 | Third
    36 |

      37 |
    • List 38 |
    • List 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | <p>No frames</p> 49 | 50 | 51 | 52 | 53 | 54 | 55 | 58 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
      73 | 74 |
      75 | 76 | 77 | 82 | 83 | 86 | 87 | 90 | 91 | 92 | Alert 93 | -------------------------------------------------------------------------------- /Jyxo/Beholder/TestCase/FileSystem.php: -------------------------------------------------------------------------------- 1 | dir = $dir; 55 | } 56 | 57 | /** 58 | * Performs the test. 59 | * 60 | * @return Result 61 | */ 62 | public function run(): Result 63 | { 64 | $random = md5(uniqid((string) time(), true)); 65 | $path = $this->dir . '/beholder-' . $random . '.txt'; 66 | $content = $random; 67 | 68 | // Writing 69 | if (!file_put_contents($path, $content)) { 70 | return new Result(Result::FAILURE, sprintf('Write error %s', $this->dir)); 71 | } 72 | 73 | // Reading 74 | $readContent = file_get_contents($path); 75 | 76 | if (strlen($readContent) !== strlen($content)) { 77 | return new Result(Result::FAILURE, sprintf('Read error %s', $this->dir)); 78 | } 79 | 80 | // Deleting 81 | if (!@unlink($path)) { 82 | return new Result(Result::FAILURE, sprintf('Delete error %s', $this->dir)); 83 | } 84 | 85 | // OK 86 | return new Result(Result::SUCCESS, $this->dir); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /Jyxo/Rpc/Xml/Server.php: -------------------------------------------------------------------------------- 1 | server = xmlrpc_server_create(); 49 | } 50 | 51 | /** 52 | * Destroys a class instance. 53 | */ 54 | public function __destruct() 55 | { 56 | parent::__destruct(); 57 | 58 | if (is_resource($this->server)) { 59 | xmlrpc_server_destroy($this->server); 60 | } 61 | } 62 | 63 | /** 64 | * Processes a request and sends a XML-RPC response. 65 | */ 66 | public function process(): void 67 | { 68 | $options = [ 69 | 'output_type' => 'xml', 70 | 'verbosity' => 'pretty', 71 | 'escaping' => ['markup'], 72 | 'version' => 'xmlrpc', 73 | 'encoding' => 'utf-8', 74 | ]; 75 | 76 | $response = xmlrpc_server_call_method($this->server, file_get_contents('php://input'), null, $options); 77 | header('Content-Type: text/xml; charset="utf-8"'); 78 | echo $response; 79 | } 80 | 81 | /** 82 | * Actually registers a function to a server method. 83 | * 84 | * @param string $func Function definition 85 | */ 86 | protected function register(string $func): void 87 | { 88 | xmlrpc_server_register_method($this->server, $func, [$this, 'call']); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /Jyxo/Input/Validator/IsBirthNumber.php: -------------------------------------------------------------------------------- 1 | 70) && ($year > 2003)) { 70 | // Females since 2004 if all 4-digit extension combinations were used that day 71 | $month -= 70; 72 | } elseif ($month > 50) { 73 | // Females 74 | $month -= 50; 75 | } elseif (($month > 20) && ($year > 2003)) { 76 | // Males since 2004 if all 4-digit extension combinations were used that day 77 | $month -= 20; 78 | } 79 | 80 | // Date check 81 | return checkdate((int) $month, (int) $day, (int) $year); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /Jyxo/Time/ComposerException.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Memcached not set'); 41 | } 42 | 43 | $ip = '127.0.0.1'; 44 | $port = '12345'; 45 | 46 | $test = new Memcached('Memcached', $ip, $port); 47 | // @ on purpose 48 | $result = @$test->run(); 49 | $this->assertEquals(Result::FAILURE, $result->getStatus()); 50 | $this->assertEquals(sprintf('Connection error %s:%s', gethostbyaddr($ip), $port), $result->getDescription()); 51 | } 52 | 53 | /** 54 | * Tests working connection. 55 | */ 56 | public function testAllOk(): void 57 | { 58 | // Skip the test if no memcache connection is defined 59 | if (empty($GLOBALS['memcache'])) { 60 | $this->markTestSkipped('Memcached not set'); 61 | } 62 | 63 | $servers = explode(',', $GLOBALS['memcache']); 64 | [$ip, $port] = explode(':', $servers[0]); 65 | 66 | $test = new Memcached('Memcached', $ip, $port); 67 | $result = $test->run(); 68 | $this->assertEquals(Result::SUCCESS, $result->getStatus()); 69 | $this->assertEquals(sprintf('%s:%s', gethostbyaddr($ip), $port), $result->getDescription()); 70 | } 71 | 72 | protected function setUp(): void 73 | { 74 | if (!class_exists('Memcached')) { 75 | $this->markTestSkipped('Memcached not set'); 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /tests/Jyxo/TimerTest.php: -------------------------------------------------------------------------------- 1 | assertGreaterThan(0, $delta); 45 | 46 | // Measured time is less than the time between the two function calls 47 | $this->assertLessThan($outerDelta, $delta); 48 | 49 | // Non-existent timer 50 | $this->assertSame(0.0, Timer::stop('foo')); 51 | 52 | // Start 4 timers 53 | $names = ['foo', 'bar', 'tmp', 'ohai']; 54 | $times = array_fill_keys($names, 0); 55 | 56 | foreach ($names as $name) { 57 | Timer::start($name); 58 | } 59 | 60 | // End them in reverse order 61 | foreach (array_reverse($names) as $name) { 62 | usleep(100); 63 | $times[$name] = Timer::stop($name); 64 | } 65 | 66 | // The measured time is supposed to be in descending order 67 | foreach ($names as $i => $name) { 68 | $this->assertGreaterThan(0, $times[$name]); 69 | 70 | if ($i > 0) { 71 | $this->assertLessThan($times[$names[$i - 1]], $times[$name]); 72 | } 73 | } 74 | } 75 | 76 | /** 77 | * Tests the timer function. 78 | */ 79 | public function testTimer(): void 80 | { 81 | Timer::timer(); 82 | 83 | for ($i = 100; $i < 1000000; $i *= 10) { 84 | usleep($i * 2); 85 | $delta = Timer::timer(); 86 | 87 | $this->assertGreaterThan($i / 1000000, $delta); 88 | } 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /Jyxo/Mail/Email/Attachment/InlineStringAttachment.php: -------------------------------------------------------------------------------- 1 | setContent($content); 56 | $this->setName($name); 57 | $this->setCid($cid); 58 | $this->setMimeType($mimeType); 59 | $this->setEncoding($encoding); 60 | } 61 | 62 | /** 63 | * Sets Id. 64 | * 65 | * @param string $cid 66 | * @return InlineStringAttachment 67 | */ 68 | public function setCid(string $cid): self 69 | { 70 | $this->cid = $cid; 71 | 72 | return $this; 73 | } 74 | 75 | /** 76 | * Sets contents encoding. 77 | * If none is set, assume no encoding is used. 78 | * 79 | * @param string $encoding Encoding name 80 | * @return InlineStringAttachment 81 | */ 82 | public function setEncoding(string $encoding): self 83 | { 84 | if (!empty($encoding) && (!Encoding::isCompatible($encoding))) { 85 | throw new InvalidArgumentException(sprintf('Incompatible encoding %s', $encoding)); 86 | } 87 | 88 | $this->encoding = $encoding; 89 | 90 | return $this; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /Jyxo/Mail/Email/Address.php: -------------------------------------------------------------------------------- 1 | setEmail($email); 55 | $this->setName($name); 56 | } 57 | 58 | /** 59 | * Returns email address. 60 | * 61 | * @return string 62 | */ 63 | public function getEmail(): string 64 | { 65 | return $this->email; 66 | } 67 | 68 | /** 69 | * Sets email address. 70 | * 71 | * @param string $email Email address 72 | * @return Address 73 | */ 74 | public function setEmail(string $email): self 75 | { 76 | $email = trim($email); 77 | 78 | // Validity check 79 | if (!IsEmail::validate($email)) { 80 | throw new InvalidArgumentException(sprintf('Invalid email address %s.', $email)); 81 | } 82 | 83 | $this->email = $email; 84 | 85 | return $this; 86 | } 87 | 88 | /** 89 | * Returns name. 90 | * 91 | * @return string 92 | */ 93 | public function getName(): string 94 | { 95 | return $this->name; 96 | } 97 | 98 | /** 99 | * Sets name. 100 | * 101 | * @param string $name Name 102 | * @return Address 103 | */ 104 | public function setName(string $name): self 105 | { 106 | $this->name = trim($name); 107 | 108 | return $this; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /Jyxo/Mail/Sender/Result.php: -------------------------------------------------------------------------------- 1 | messageId; 58 | } 59 | 60 | /** 61 | * Sets email Id. 62 | * 63 | * @param string $messageId Email Id 64 | * @return Result 65 | */ 66 | public function setMessageId(string $messageId): self 67 | { 68 | $this->messageId = $messageId; 69 | 70 | return $this; 71 | } 72 | 73 | /** 74 | * Returns email source. 75 | * 76 | * @return string 77 | */ 78 | public function getSource(): string 79 | { 80 | return $this->source; 81 | } 82 | 83 | /** 84 | * Sets email source. 85 | * 86 | * @param string $source 87 | * @return Result 88 | */ 89 | public function setSource(string $source): self 90 | { 91 | $this->source = $source; 92 | 93 | return $this; 94 | } 95 | 96 | /** 97 | * Returns sending time. 98 | * 99 | * @return Time 100 | */ 101 | public function getDatetime(): Time 102 | { 103 | return $this->datetime; 104 | } 105 | 106 | /** 107 | * Sets sending time. 108 | * 109 | * @param Time $datetime Sending time 110 | * @return Result 111 | */ 112 | public function setDatetime(Time $datetime): self 113 | { 114 | $this->datetime = $datetime; 115 | 116 | return $this; 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /Jyxo/Rpc/Xml/Client.php: -------------------------------------------------------------------------------- 1 | options = [ 43 | 'output_type' => 'xml', 44 | 'verbosity' => 'pretty', 45 | 'escaping' => ['markup'], 46 | 'version' => 'xmlrpc', 47 | 'encoding' => 'utf-8', 48 | ]; 49 | } 50 | 51 | /** 52 | * Sends request and fetches server's response. 53 | * 54 | * @param string $method Method name 55 | * @param array $params Method parameters 56 | * @return mixed 57 | */ 58 | public function send(string $method, array $params) 59 | { 60 | // Start profiling 61 | $this->profileStart(); 62 | 63 | try { 64 | // Fetch response 65 | $response = $this->process('text/xml', xmlrpc_encode_request($method, $params, $this->options)); 66 | 67 | // Process response 68 | $response = xmlrpc_decode($response, 'utf-8'); 69 | 70 | } catch (\Jyxo\Rpc\Exception $e) { 71 | // Finish profiling 72 | $this->profileEnd('XML', $method, $params, $e->getMessage()); 73 | 74 | throw new Exception($e->getMessage(), 0, $e); 75 | } 76 | 77 | // Finish profiling 78 | $this->profileEnd('XML', $method, $params, $response); 79 | 80 | // Error in response 81 | if (is_array($response) && (isset($response['faultString']))) { 82 | throw new Exception(preg_replace('~\\s+~', ' ', $response['faultString'])); 83 | } 84 | 85 | return $response; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /Jyxo/Mail/Email/Body.php: -------------------------------------------------------------------------------- 1 | setMain($main); 52 | $this->setAlternative($alternative); 53 | } 54 | 55 | /** 56 | * Returns if the contents is in HTML format. 57 | * 58 | * @return bool 59 | */ 60 | public function isHtml(): bool 61 | { 62 | return Html::is($this->main); 63 | } 64 | 65 | /** 66 | * Returns main body contents. 67 | * 68 | * @return string 69 | */ 70 | public function getMain(): string 71 | { 72 | return $this->main; 73 | } 74 | 75 | /** 76 | * Sets main body contents. 77 | * 78 | * @param string $main Contents 79 | * @return Body 80 | */ 81 | public function setMain(string $main): self 82 | { 83 | $this->main = $main; 84 | 85 | return $this; 86 | } 87 | 88 | /** 89 | * Returns alternative body contents. 90 | * 91 | * @return string 92 | */ 93 | public function getAlternative(): string 94 | { 95 | return $this->alternative; 96 | } 97 | 98 | /** 99 | * Sets alternative body contents. 100 | * 101 | * @param string $alternative Contents 102 | * @return Body 103 | */ 104 | public function setAlternative(string $alternative): self 105 | { 106 | $this->alternative = $alternative; 107 | 108 | return $this; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /tests/Jyxo/Beholder/TestCase/SmtpTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped(sprintf('%s already loaded', \Jyxo\Mail\Sender\Smtp::class)); 39 | } 40 | 41 | $test = new Smtp('Smtp', '', '', ''); 42 | 43 | // Turns autoload off 44 | $this->disableAutoload(); 45 | 46 | $result = $test->run(); 47 | 48 | // Turns autoload on 49 | $this->enableAutoload(); 50 | 51 | $this->assertEquals(Result::NOT_APPLICABLE, $result->getStatus()); 52 | $this->assertEquals(sprintf('Class %s missing', \Jyxo\Mail\Sender\Smtp::class), $result->getDescription()); 53 | } 54 | 55 | /** 56 | * Tests for a sending failure. 57 | */ 58 | public function testSendFailure(): void 59 | { 60 | $test = new Smtp('Smtp', 'dummy.jyxo.com', '', ''); 61 | $result = $test->run(); 62 | $this->assertEquals(Result::FAILURE, $result->getStatus()); 63 | $this->assertEquals('Send error dummy.jyxo.com', $result->getDescription()); 64 | } 65 | 66 | /** 67 | * Tests for a successful sending. 68 | */ 69 | public function testSendOk(): void 70 | { 71 | // Skips the test if no SMTP connection is defined 72 | if (empty($GLOBALS['smtp'])) { 73 | $this->markTestSkipped('Smtp host not set'); 74 | } 75 | 76 | $test = new Smtp('Smtp', $GLOBALS['smtp'], 'blog-noreply@blog.cz'); 77 | $result = $test->run(); 78 | $this->assertEquals(Result::SUCCESS, $result->getStatus()); 79 | $this->assertEquals($GLOBALS['smtp'], $result->getDescription()); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /Jyxo/Input/Chain/Conditional.php: -------------------------------------------------------------------------------- 1 | setCondValidator($validator); 47 | } 48 | } 49 | 50 | /** 51 | * Validates a value. 52 | * 53 | * @param mixed $value Input value 54 | * @return bool 55 | */ 56 | public function isValid($value): bool 57 | { 58 | // Validation is performed only if the condition is fulfilled 59 | if ($this->checkCondition($value) === true) { 60 | return parent::isValid($value); 61 | } 62 | 63 | // No validation -> the value is valid 64 | $this->value = $value; 65 | 66 | return true; 67 | } 68 | 69 | /** 70 | * Sets the condition validator. 71 | * 72 | * @param ValidatorInterface $validator Condition validator 73 | * @return Conditional 74 | */ 75 | public function setCondValidator(ValidatorInterface $validator): self 76 | { 77 | $this->condValidator = $validator; 78 | 79 | return $this; 80 | } 81 | 82 | /** 83 | * Checks if the condition is fulfilled. 84 | * 85 | * @param mixed $value Input value 86 | * @return bool 87 | */ 88 | private function checkCondition($value): bool 89 | { 90 | if ($this->condValidator === null) { 91 | // There is no validator -> always fulfilled 92 | return true; 93 | } 94 | 95 | return $this->condValidator->isValid($value); 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /tests/Jyxo/Mail/Email/Attachment/StringAttachmentTest.php: -------------------------------------------------------------------------------- 1 | assertEquals($content, $attachment->getContent()); 48 | $this->assertEquals($name, $attachment->getName()); 49 | $this->assertEquals($mimeType, $attachment->getMimeType()); 50 | $this->assertEquals(Attachment::DISPOSITION_ATTACHMENT, $attachment->getDisposition()); 51 | $this->assertFalse($attachment->isInline()); 52 | $this->assertEquals('', $attachment->getCid()); 53 | $this->assertEquals('', $attachment->getEncoding()); 54 | 55 | // It is possible to set an encoding 56 | $reflection = new ReflectionClass(Encoding::class); 57 | 58 | foreach ($reflection->getConstants() as $encoding) { 59 | $attachment->setEncoding($encoding); 60 | $this->assertEquals($encoding, $attachment->getEncoding()); 61 | } 62 | 63 | // Incompatible encoding 64 | try { 65 | $attachment->setEncoding('dummy-encoding'); 66 | $this->fail(sprintf('Expected exception %s.', InvalidArgumentException::class)); 67 | } catch (AssertionFailedError $e) { 68 | throw $e; 69 | } catch (Throwable $e) { 70 | // Correctly thrown exception 71 | $this->assertInstanceOf(InvalidArgumentException::class, $e); 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /tests/Jyxo/Mail/Email/Attachment/InlineStringAttachmentTest.php: -------------------------------------------------------------------------------- 1 | assertEquals($content, $attachment->getContent()); 49 | $this->assertEquals($name, $attachment->getName()); 50 | $this->assertEquals($mimeType, $attachment->getMimeType()); 51 | $this->assertEquals(Attachment::DISPOSITION_INLINE, $attachment->getDisposition()); 52 | $this->assertTrue($attachment->isInline()); 53 | $this->assertEquals($cid, $attachment->getCid()); 54 | $this->assertEquals('', $attachment->getEncoding()); 55 | 56 | // It is possible to set an encoding 57 | $reflection = new ReflectionClass(Encoding::class); 58 | 59 | foreach ($reflection->getConstants() as $encoding) { 60 | $attachment->setEncoding($encoding); 61 | $this->assertEquals($encoding, $attachment->getEncoding()); 62 | } 63 | 64 | // Incompatible encoding 65 | try { 66 | $attachment->setEncoding('dummy-encoding'); 67 | $this->fail(sprintf('Expected exception %s.', InvalidArgumentException::class)); 68 | } catch (AssertionFailedError $e) { 69 | throw $e; 70 | } catch (Throwable $e) { 71 | // Correctly thrown exception 72 | $this->assertInstanceOf(InvalidArgumentException::class, $e); 73 | } 74 | } 75 | 76 | } 77 | --------------------------------------------------------------------------------