Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
5aee7c10
Commit
5aee7c10
authored
11 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
lint: Add first of tests for mail parsing
parent
24deecf3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
setup/test/tests/mockdb.php
+82
-0
82 additions, 0 deletions
setup/test/tests/mockdb.php
setup/test/tests/test.mail-parse.php
+53
-0
53 additions, 0 deletions
setup/test/tests/test.mail-parse.php
with
135 additions
and
0 deletions
setup/test/tests/mockdb.php
0 → 100644
+
82
−
0
View file @
5aee7c10
<?php
function
db_connect
(
$source
)
{
global
$__db
;
$__db
=
$source
;
}
function
db_input
(
$what
)
{
return
sprintf
(
"'%8.8s'"
,
md5
(
$what
));
}
function
db_query
(
$sql
)
{
global
$__db
;
return
$__db
->
query
(
$sql
);
}
function
db_fetch_row
(
$res
)
{
return
$res
->
fetch_row
();
}
function
db_fetch_array
(
$res
)
{
return
$res
->
fetch_array
();
}
function
db_affected_row
()
{
global
$__db
;
return
$__db
->
affected_rows
;
}
function
db_insert_id
()
{
global
$__db
;
return
$__db
->
insert_id
;
}
function
db_num_rows
(
$res
)
{
return
$res
->
num_rows
();
}
class
MockDbSource
{
var
$insert_id
=
1
;
var
$affected_rows
=
1
;
var
$data
;
function
__construct
(
$data
=
array
())
{
$this
->
data
=
$data
;
}
function
query
(
$sql
)
{
$hash
=
md5
(
$sql
);
if
(
!
isset
(
$this
->
data
[
$sql
]))
print
(
$hash
.
": No data found:
\n
"
.
$sql
.
"
\n
"
);
return
new
MockDbCursor
(
$this
->
data
[
$hash
]
?:
array
());
}
function
addRecordset
(
$hash
,
&
$data
)
{
$this
->
data
[
$hash
]
=
$data
;
}
}
class
MockDbCursor
{
var
$data
;
function
__construct
(
$data
)
{
$this
->
data
=
$data
;
}
function
fetch_row
()
{
list
(
$i
,
$row
)
=
each
(
$this
->
data
);
return
$row
;
}
function
fetch_array
()
{
list
(
$i
,
$row
)
=
each
(
$this
->
data
);
return
$row
;
}
function
num_rows
()
{
return
count
(
$this
->
data
);
}
}
This diff is collapsed.
Click to expand it.
setup/test/tests/test.mail-parse.php
0 → 100644
+
53
−
0
View file @
5aee7c10
<?php
require_once
INCLUDE_DIR
.
'class.validator.php'
;
require_once
INCLUDE_DIR
.
'class.auth.php'
;
require_once
INCLUDE_DIR
.
'class.staff.php'
;
require_once
INCLUDE_DIR
.
'class.email.php'
;
require_once
INCLUDE_DIR
.
'class.format.php'
;
require_once
INCLUDE_DIR
.
'class.thread.php'
;
require_once
'mockdb.php'
;
class
TestMailParsing
extends
Test
{
var
$name
=
"Mail parsing library tests"
;
function
testRecipients
()
{
db_connect
(
new
MockDbSource
());
$email
=
<<<EOF
Delivered-To: jared@osticket.com
Received: by 10.60.55.168 with SMTP id t8csp161432oep;
Fri, 7 Feb 2014 22:11:19 -0800 (PST)
X-Received: by 10.182.18.9 with SMTP id s9mr16356699obd.15.1391839879167;
Fri, 07 Feb 2014 22:11:19 -0800 (PST)
Return-Path: <mailer@greezybacon.supportsystem.com>
To: jared@osticket.com
Subject: =?utf-8?Q?System_test_email_=C2=AE?=
Content-Type: multipart/alternative;
boundary="=_28022448a1f58a3af7edf57ff2e3af44"
From: "Support" <help@supportsystem.com>
Date: Sat, 08 Feb 2014 01:11:18 -0500
Message-ID: <Syke6-g24hwuTu77-help@supportsystem.com>
MIME-Version: 1.0
--=_28022448a1f58a3af7edf57ff2e3af44
Content-Transfer-Encoding: base64
Content-Type: text/plain; charset=utf-8
Q2hlZXJzISE=
--=_28022448a1f58a3af7edf57ff2e3af44
Content-Transfer-Encoding: base64
Content-Type: text/html; charset=utf-8
Q2hlZXJzISE=
--=_28022448a1f58a3af7edf57ff2e3af44--
EOF;
$result
=
EmailDataParser
::
parse
(
$email
);
$this
->
assert
(
count
(
$result
[
'recipients'
])
==
1
,
'Expected 1 recipient'
);
$this
->
assert
(
$result
[
'recipients'
][
0
][
'source'
]
==
'delivered-to'
,
'Delivered-To header used as a collaborator'
);
}
}
return
'TestMailParsing'
;
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment