Skip to content

Commit 7026f4c

Browse files
committed
Using the assertSame to make assertion restricted
1 parent f839347 commit 7026f4c

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

tests/BacktraceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function test_backtrace_in_failed_complex_matching() : void
8787
// Uncomment when backtrace logic changes, run tests and then commit again.
8888
\file_put_contents(__DIR__ . '/BacktraceTest/failed_complex_matching_expected_trace.txt', (string) $this->matcher->backtrace());
8989

90-
$this->assertEquals(
90+
$this->assertSame(
9191
\file_get_contents(__DIR__ . '/BacktraceTest/failed_complex_matching_expected_trace.txt'),
9292
(string) $this->matcher->backtrace()
9393
);
@@ -143,7 +143,7 @@ public function test_backtrace_in_succeed_complex_matching() : void
143143
// Uncomment when backtrace logic changes, run tests and then commit again.
144144
\file_put_contents(__DIR__ . '/BacktraceTest/succeed_complex_matching_expected_trace.txt', (string) $this->matcher->backtrace());
145145

146-
$this->assertEquals(
146+
$this->assertSame(
147147
\file_get_contents(__DIR__ . '/BacktraceTest/succeed_complex_matching_expected_trace.txt'),
148148
(string) $this->matcher->backtrace()
149149
);

tests/LexerTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public function test_string_values(string $value) : void
8686
$lexer = new Lexer();
8787
$lexer->setInput($value);
8888
$lexer->moveNext();
89-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_STRING);
90-
$this->assertEquals($lexer->lookahead['value'], \trim(\trim($value, "'"), '"'));
89+
$this->assertSame($lexer->lookahead['type'], Lexer::T_STRING);
90+
$this->assertSame($lexer->lookahead['value'], \trim(\trim($value, "'"), '"'));
9191
}
9292

9393
/**
@@ -98,8 +98,8 @@ public function test_number_values($value, $expectedValue) : void
9898
$lexer = new Lexer();
9999
$lexer->setInput($value);
100100
$lexer->moveNext();
101-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_NUMBER);
102-
$this->assertEquals($expectedValue, $lexer->lookahead['value']);
101+
$this->assertSame($lexer->lookahead['type'], Lexer::T_NUMBER);
102+
$this->assertSame($expectedValue, $lexer->lookahead['value']);
103103
}
104104

105105
/**
@@ -110,8 +110,8 @@ public function test_boolean_values($value, $expectedValue) : void
110110
$lexer = new Lexer();
111111
$lexer->setInput($value);
112112
$lexer->moveNext();
113-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_BOOLEAN);
114-
$this->assertEquals($lexer->lookahead['value'], $expectedValue);
113+
$this->assertSame($lexer->lookahead['type'], Lexer::T_BOOLEAN);
114+
$this->assertSame($lexer->lookahead['value'], $expectedValue);
115115
}
116116

117117
/**
@@ -122,7 +122,7 @@ public function test_null_values($value) : void
122122
$lexer = new Lexer();
123123
$lexer->setInput($value);
124124
$lexer->moveNext();
125-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_NULL);
125+
$this->assertSame($lexer->lookahead['type'], Lexer::T_NULL);
126126
$this->assertNull($lexer->lookahead['value']);
127127
}
128128

@@ -134,47 +134,47 @@ public function test_non_token_values($value) : void
134134
$lexer = new Lexer();
135135
$lexer->setInput($value);
136136
$lexer->moveNext();
137-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_NONE);
137+
$this->assertSame($lexer->lookahead['type'], Lexer::T_NONE);
138138
}
139139

140140
public function test_close_parenthesis() : void
141141
{
142142
$lexer = new Lexer();
143143
$lexer->setInput(')');
144144
$lexer->moveNext();
145-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_CLOSE_PARENTHESIS);
145+
$this->assertSame($lexer->lookahead['type'], Lexer::T_CLOSE_PARENTHESIS);
146146
}
147147

148148
public function test_close_open_brace() : void
149149
{
150150
$lexer = new Lexer();
151151
$lexer->setInput('{');
152152
$lexer->moveNext();
153-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_OPEN_CURLY_BRACE);
153+
$this->assertSame($lexer->lookahead['type'], Lexer::T_OPEN_CURLY_BRACE);
154154
}
155155

156156
public function test_close_curly_brace() : void
157157
{
158158
$lexer = new Lexer();
159159
$lexer->setInput('}');
160160
$lexer->moveNext();
161-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_CLOSE_CURLY_BRACE);
161+
$this->assertSame($lexer->lookahead['type'], Lexer::T_CLOSE_CURLY_BRACE);
162162
}
163163

164164
public function test_colon() : void
165165
{
166166
$lexer = new Lexer();
167167
$lexer->setInput(':');
168168
$lexer->moveNext();
169-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_COLON);
169+
$this->assertSame($lexer->lookahead['type'], Lexer::T_COLON);
170170
}
171171

172172
public function test_comma() : void
173173
{
174174
$lexer = new Lexer();
175175
$lexer->setInput(',');
176176
$lexer->moveNext();
177-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_COMMA);
177+
$this->assertSame($lexer->lookahead['type'], Lexer::T_COMMA);
178178
}
179179

180180
/**
@@ -185,8 +185,8 @@ public function test_type_pattern($value) : void
185185
$lexer = new Lexer();
186186
$lexer->setInput($value);
187187
$lexer->moveNext();
188-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_TYPE_PATTERN);
189-
$this->assertEquals($lexer->lookahead['value'], \trim($value, '@'));
188+
$this->assertSame($lexer->lookahead['type'], Lexer::T_TYPE_PATTERN);
189+
$this->assertSame($lexer->lookahead['value'], \trim($value, '@'));
190190
}
191191

192192
/**
@@ -197,8 +197,8 @@ public function test_expander_name($value, $expectedTokenValue) : void
197197
$lexer = new Lexer();
198198
$lexer->setInput($value);
199199
$lexer->moveNext();
200-
$this->assertEquals($lexer->lookahead['type'], Lexer::T_EXPANDER_NAME);
201-
$this->assertEquals($lexer->lookahead['value'], $expectedTokenValue);
200+
$this->assertSame($lexer->lookahead['type'], Lexer::T_EXPANDER_NAME);
201+
$this->assertSame($lexer->lookahead['value'], $expectedTokenValue);
202202
}
203203

204204
public function test_ignore_whitespaces_between_parenthesis() : void
@@ -207,7 +207,7 @@ public function test_ignore_whitespaces_between_parenthesis() : void
207207
$lexer = new Lexer();
208208
$lexer->setInput("@[email protected]( 'arg1', 2 ,'arg3',4)");
209209

210-
$this->assertEquals($expectedTokens, $this->collectTokens($lexer));
210+
$this->assertSame($expectedTokens, $this->collectTokens($lexer));
211211
}
212212

213213
/**

tests/ParserTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,32 +77,32 @@ public function test_simple_pattern_without_expanders() : void
7777
{
7878
$pattern = '@type@';
7979

80-
$this->assertEquals('type', $this->parser->getAST($pattern)->getType());
80+
$this->assertSame('type', (string) $this->parser->getAST($pattern)->getType());
8181
$this->assertFalse($this->parser->getAST($pattern)->hasExpanders());
8282
}
8383

8484
public function test_single_expander_without_args() : void
8585
{
8686
$pattern = '@[email protected]()';
8787

88-
$this->assertEquals('type', $this->parser->getAST($pattern)->getType());
88+
$this->assertSame('type', (string) $this->parser->getAST($pattern)->getType());
8989
$expanders = $this->parser->getAST($pattern)->getExpanders();
90-
$this->assertEquals('expander', $expanders[0]->getName());
90+
$this->assertSame('expander', $expanders[0]->getName());
9191
$this->assertFalse($expanders[0]->hasArguments());
9292
}
9393

9494
public function test_single_expander_with_arguments() : void
9595
{
9696
$pattern = "@[email protected]('arg1', 2, 2.24, \"arg3\")";
97-
$this->assertEquals('type', $this->parser->getAST($pattern)->getType());
97+
$this->assertSame('type', (string) $this->parser->getAST($pattern)->getType());
9898
$expanders = $this->parser->getAST($pattern)->getExpanders();
9999
$expectedArguments = [
100100
'arg1',
101101
2,
102102
2.24,
103103
'arg3',
104104
];
105-
$this->assertEquals($expectedArguments, $expanders[0]->getArguments());
105+
$this->assertSame($expectedArguments, $expanders[0]->getArguments());
106106
}
107107

108108
public function test_many_expanders() : void
@@ -115,14 +115,14 @@ public function test_many_expanders() : void
115115
];
116116

117117
$expanders = $this->parser->getAST($pattern)->getExpanders();
118-
$this->assertEquals('type', $this->parser->getAST($pattern)->getType());
119-
$this->assertEquals('expander', $expanders[0]->getName());
120-
$this->assertEquals('expander1', $expanders[1]->getName());
121-
$this->assertEquals('expander', $expanders[2]->getName());
122-
123-
$this->assertEquals($expanderArguments[0], $expanders[0]->getArguments());
124-
$this->assertEquals($expanderArguments[1], $expanders[1]->getArguments());
125-
$this->assertEquals($expanderArguments[2], $expanders[2]->getArguments());
118+
$this->assertSame('type', (string) $this->parser->getAST($pattern)->getType());
119+
$this->assertSame('expander', $expanders[0]->getName());
120+
$this->assertSame('expander1', $expanders[1]->getName());
121+
$this->assertSame('expander', $expanders[2]->getName());
122+
123+
$this->assertSame($expanderArguments[0], $expanders[0]->getArguments());
124+
$this->assertSame($expanderArguments[1], $expanders[1]->getArguments());
125+
$this->assertSame($expanderArguments[2], $expanders[2]->getArguments());
126126
}
127127

128128
/**
@@ -131,7 +131,7 @@ public function test_many_expanders() : void
131131
public function test_single_array_argument_with_string_key_value($pattern, $expectedArgument) : void
132132
{
133133
$expanders = $this->parser->getAST($pattern)->getExpanders();
134-
$this->assertEquals($expectedArgument, $expanders[0]->getArguments());
134+
$this->assertSame($expectedArgument, $expanders[0]->getArguments());
135135
}
136136

137137
public function test_expanders_that_takes_other_expanders_as_arguments() : void

0 commit comments

Comments
 (0)