Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
75f72d54
Unverified
Commit
75f72d54
authored
Jul 06, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use better PHPUnit assertions for TelegramLog tests.
parent
9a66af0d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
TelegramLogTest.php
tests/Unit/TelegramLogTest.php
+12
-12
No files found.
tests/Unit/TelegramLogTest.php
View file @
75f72d54
...
@@ -29,10 +29,10 @@ class TelegramLogTest extends TestCase
...
@@ -29,10 +29,10 @@ class TelegramLogTest extends TestCase
* @var array Dummy logfile paths
* @var array Dummy logfile paths
*/
*/
private
$logfiles
=
[
private
$logfiles
=
[
'error'
=>
'/tmp/errorlog.log'
,
'error'
=>
'/tmp/
php-telegram-bot-
errorlog.log'
,
'debug'
=>
'/tmp/debuglog.log'
,
'debug'
=>
'/tmp/
php-telegram-bot-
debuglog.log'
,
'update'
=>
'/tmp/updatelog.log'
,
'update'
=>
'/tmp/
php-telegram-bot-
updatelog.log'
,
'external'
=>
'/tmp/externallog.log'
,
'external'
=>
'/tmp/
php-telegram-bot-
externallog.log'
,
];
];
/**
/**
...
@@ -82,37 +82,37 @@ class TelegramLogTest extends TestCase
...
@@ -82,37 +82,37 @@ class TelegramLogTest extends TestCase
public
function
testErrorStream
()
public
function
testErrorStream
()
{
{
$file
=
$this
->
logfiles
[
'error'
];
$file
=
$this
->
logfiles
[
'error'
];
$this
->
assertF
alse
(
file_exists
(
$file
)
);
$this
->
assertF
ileNotExists
(
$file
);
TelegramLog
::
initErrorLog
(
$file
);
TelegramLog
::
initErrorLog
(
$file
);
TelegramLog
::
error
(
'my error'
);
TelegramLog
::
error
(
'my error'
);
$this
->
assert
True
(
file_exists
(
$file
)
);
$this
->
assert
FileExists
(
$file
);
$this
->
assertContains
(
'bot_log.ERROR: my error'
,
file_get_contents
(
$file
));
$this
->
assertContains
(
'bot_log.ERROR: my error'
,
file_get_contents
(
$file
));
}
}
public
function
testDebugStream
()
public
function
testDebugStream
()
{
{
$file
=
$this
->
logfiles
[
'debug'
];
$file
=
$this
->
logfiles
[
'debug'
];
$this
->
assertF
alse
(
file_exists
(
$file
)
);
$this
->
assertF
ileNotExists
(
$file
);
TelegramLog
::
initDebugLog
(
$file
);
TelegramLog
::
initDebugLog
(
$file
);
TelegramLog
::
debug
(
'my debug'
);
TelegramLog
::
debug
(
'my debug'
);
$this
->
assert
True
(
file_exists
(
$file
)
);
$this
->
assert
FileExists
(
$file
);
$this
->
assertContains
(
'bot_log.DEBUG: my debug'
,
file_get_contents
(
$file
));
$this
->
assertContains
(
'bot_log.DEBUG: my debug'
,
file_get_contents
(
$file
));
}
}
public
function
testUpdateStream
()
public
function
testUpdateStream
()
{
{
$file
=
$this
->
logfiles
[
'update'
];
$file
=
$this
->
logfiles
[
'update'
];
$this
->
assertF
alse
(
file_exists
(
$file
)
);
$this
->
assertF
ileNotExists
(
$file
);
TelegramLog
::
initUpdateLog
(
$file
);
TelegramLog
::
initUpdateLog
(
$file
);
TelegramLog
::
update
(
'my update'
);
TelegramLog
::
update
(
'my update'
);
$this
->
assert
True
(
file_exists
(
$file
)
);
$this
->
assert
FileExists
(
$file
);
$this
->
assertContains
(
'my update'
,
file_get_contents
(
$file
));
$this
->
assertContains
(
'my update'
,
file_get_contents
(
$file
));
}
}
public
function
testExternalStream
()
public
function
testExternalStream
()
{
{
$file
=
$this
->
logfiles
[
'external'
];
$file
=
$this
->
logfiles
[
'external'
];
$this
->
assertF
alse
(
file_exists
(
$file
)
);
$this
->
assertF
ileNotExists
(
$file
);
$external_monolog
=
new
Logger
(
'bot_update_log'
);
$external_monolog
=
new
Logger
(
'bot_update_log'
);
$external_monolog
->
pushHandler
(
new
StreamHandler
(
$file
,
Logger
::
ERROR
));
$external_monolog
->
pushHandler
(
new
StreamHandler
(
$file
,
Logger
::
ERROR
));
...
@@ -122,7 +122,7 @@ class TelegramLogTest extends TestCase
...
@@ -122,7 +122,7 @@ class TelegramLogTest extends TestCase
TelegramLog
::
error
(
'my error'
);
TelegramLog
::
error
(
'my error'
);
TelegramLog
::
debug
(
'my debug'
);
TelegramLog
::
debug
(
'my debug'
);
$this
->
assert
True
(
file_exists
(
$file
)
);
$this
->
assert
FileExists
(
$file
);
$file_contents
=
file_get_contents
(
$file
);
$file_contents
=
file_get_contents
(
$file
);
$this
->
assertContains
(
'bot_update_log.ERROR: my error'
,
$file_contents
);
$this
->
assertContains
(
'bot_update_log.ERROR: my error'
,
$file_contents
);
$this
->
assertContains
(
'bot_update_log.DEBUG: my debug'
,
$file_contents
);
$this
->
assertContains
(
'bot_update_log.DEBUG: my debug'
,
$file_contents
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment