Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
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
Tomáš Trávníček
doctrine-dbal
Commits
521d6340
Commit
521d6340
authored
Jan 16, 2008
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
394152e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
0 deletions
+105
-0
ScannerTestCase.php
draft/tests/ScannerTestCase.php
+105
-0
No files found.
draft/tests/ScannerTestCase.php
0 → 100644
View file @
521d6340
<?php
spl_autoload_register
(
array
(
'Doctrine'
,
'autoload'
));
class
Doctrine_Query_Scanner_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testScannerRecognizesIdentifierWithLengthOfOneCharacter
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
'u'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_IDENTIFIER
,
$token
->
getType
());
$this
->
assertEquals
(
'u'
,
$token
->
getValue
());
}
public
function
testScannerRecognizesIdentifierConsistingOfLetters
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
'someIdentifier'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_IDENTIFIER
,
$token
->
getType
());
$this
->
assertEquals
(
'someIdentifier'
,
$token
->
getValue
());
}
public
function
testScannerRecognizesIdentifierIncludingDigits
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
's0m31d3nt1f13r'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_IDENTIFIER
,
$token
->
getType
());
$this
->
assertEquals
(
's0m31d3nt1f13r'
,
$token
->
getValue
());
}
public
function
testScannerRecognizesIdentifierIncludingUnderscore
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
'some_identifier'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_IDENTIFIER
,
$token
->
getType
());
$this
->
assertEquals
(
'some_identifier'
,
$token
->
getValue
());
}
public
function
testScannerRecognizesDecimalInteger
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
'1234'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_NUMERIC
,
$token
->
getType
());
$this
->
assertEquals
(
1234
,
$token
->
getValue
());
}
public
function
testScannerRecognizesNegativeDecimalInteger
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
'-123'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_NUMERIC
,
$token
->
getType
());
$this
->
assertEquals
(
-
123
,
$token
->
getValue
());
}
public
function
testScannerRecognizesFloat
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
'1.234'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_NUMERIC
,
$token
->
getType
());
$this
->
assertEquals
(
1.234
,
$token
->
getValue
());
}
public
function
testScannerRecognizesFloatWithExponent
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
'1.2e3'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_NUMERIC
,
$token
->
getType
());
$this
->
assertEquals
(
1.2e3
,
$token
->
getValue
());
}
public
function
testScannerRecognizesFloatWithNegativeExponent
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
'7E-10'
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_NUMERIC
,
$token
->
getType
());
$this
->
assertEquals
(
7E-10
,
$token
->
getValue
());
}
public
function
testScannerRecognizesStringContainingWhitespace
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
"'This is a string.'"
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_STRING
,
$token
->
getType
());
$this
->
assertEquals
(
"'This is a string.'"
,
$token
->
getValue
());
}
public
function
testScannerRecognizesStringContainingSingleQuotes
()
{
$scanner
=
new
Doctrine_Query_Scanner
(
"'abc''defg'''"
);
$token
=
$scanner
->
scan
();
$this
->
assertEquals
(
Doctrine_Query_Token
::
T_STRING
,
$token
->
getType
());
$this
->
assertEquals
(
"'abc''defg'''"
,
$token
->
getValue
());
}
}
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