Skip to content

Commit 77c04bd

Browse files
committed
test: replace assertEquals with assertSame
1 parent be10bab commit 77c04bd

1 file changed

Lines changed: 34 additions & 34 deletions

File tree

tests/SpanTest.php

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public function testConstructorSetsSpanAttributes(): void
2727
$this->assertIsString($traceId);
2828
$this->assertIsString($spanId);
2929
$this->assertIsFloat($startedAt);
30-
$this->assertEquals(32, strlen($traceId));
31-
$this->assertEquals(16, strlen($spanId));
30+
$this->assertSame(32, strlen($traceId));
31+
$this->assertSame(16, strlen($spanId));
3232
}
3333

3434
public function testSetAndGet(): void
@@ -37,7 +37,7 @@ public function testSetAndGet(): void
3737

3838
$span->set('key', 'value');
3939

40-
$this->assertEquals('value', $span->get('key'));
40+
$this->assertSame('value', $span->get('key'));
4141
}
4242

4343
public function testSetReturnsself(): void
@@ -61,31 +61,31 @@ public function testSetAcceptsString(): void
6161
$span = new Span();
6262
$span->set('key', 'string value');
6363

64-
$this->assertEquals('string value', $span->get('key'));
64+
$this->assertSame('string value', $span->get('key'));
6565
}
6666

6767
public function testSetAcceptsInt(): void
6868
{
6969
$span = new Span();
7070
$span->set('key', 42);
7171

72-
$this->assertEquals(42, $span->get('key'));
72+
$this->assertSame(42, $span->get('key'));
7373
}
7474

7575
public function testSetAcceptsFloat(): void
7676
{
7777
$span = new Span();
7878
$span->set('key', 3.14);
7979

80-
$this->assertEquals(3.14, $span->get('key'));
80+
$this->assertSame(3.14, $span->get('key'));
8181
}
8282

8383
public function testSetAcceptsBool(): void
8484
{
8585
$span = new Span();
8686
$span->set('key', true);
8787

88-
$this->assertEquals(true, $span->get('key'));
88+
$this->assertSame(true, $span->get('key'));
8989
}
9090

9191
public function testSetAcceptsNull(): void
@@ -104,8 +104,8 @@ public function testGetAttributesReturnsAllAttributes(): void
104104

105105
$attributes = $span->getAttributes();
106106

107-
$this->assertEquals('value1', $attributes['key1']);
108-
$this->assertEquals('value2', $attributes['key2']);
107+
$this->assertSame('value1', $attributes['key1']);
108+
$this->assertSame('value2', $attributes['key2']);
109109
$this->assertArrayHasKey('span.trace_id', $attributes);
110110
$this->assertArrayHasKey('span.id', $attributes);
111111
$this->assertArrayHasKey('span.started_at', $attributes);
@@ -118,9 +118,9 @@ public function testSetErrorSetsErrorAttributes(): void
118118

119119
$span->setError($error);
120120

121-
$this->assertEquals(RuntimeException::class, $span->get('error.type'));
122-
$this->assertEquals('Test error', $span->get('error.message'));
123-
$this->assertEquals(42, $span->get('error.code'));
121+
$this->assertSame(RuntimeException::class, $span->get('error.type'));
122+
$this->assertSame('Test error', $span->get('error.message'));
123+
$this->assertSame(42, $span->get('error.code'));
124124
$this->assertIsString($span->get('error.file'));
125125
$this->assertIsInt($span->get('error.line'));
126126
}
@@ -208,7 +208,7 @@ public function testAddSetsAttributeOnCurrentSpan(): void
208208

209209
Span::add('key', 'value');
210210

211-
$this->assertEquals('value', $span->get('key'));
211+
$this->assertSame('value', $span->get('key'));
212212
}
213213

214214
public function testAddDoesNothingWhenNoCurrentSpan(): void
@@ -225,7 +225,7 @@ public function testErrorSetsErrorOnCurrentSpan(): void
225225

226226
Span::error(new RuntimeException('Test'));
227227

228-
$this->assertEquals(RuntimeException::class, $span->get('error.type'));
228+
$this->assertSame(RuntimeException::class, $span->get('error.type'));
229229
}
230230

231231
public function testErrorDoesNothingWhenNoCurrentSpan(): void
@@ -358,7 +358,7 @@ public function testSetOverwritesExistingAttribute(): void
358358
$span->set('key', 'value1');
359359
$span->set('key', 'value2');
360360

361-
$this->assertEquals('value2', $span->get('key'));
361+
$this->assertSame('value2', $span->get('key'));
362362
}
363363

364364
public function testMultipleSpansInSequence(): void
@@ -376,8 +376,8 @@ public function testMultipleSpansInSequence(): void
376376
$span2->finish();
377377

378378
$this->assertCount(2, $exported);
379-
$this->assertEquals('first', $exported[0]->get('name'));
380-
$this->assertEquals('second', $exported[1]->get('name'));
379+
$this->assertSame('first', $exported[0]->get('name'));
380+
$this->assertSame('second', $exported[1]->get('name'));
381381
}
382382

383383
public function testFinishWithoutExportersDoesNotThrow(): void
@@ -419,7 +419,7 @@ public function testCanOverwriteBuiltInAttributes(): void
419419

420420
$span->set('span.trace_id', $customTraceId);
421421

422-
$this->assertEquals($customTraceId, $span->get('span.trace_id'));
422+
$this->assertSame($customTraceId, $span->get('span.trace_id'));
423423
}
424424

425425
public function testSetParentId(): void
@@ -429,7 +429,7 @@ public function testSetParentId(): void
429429

430430
$span->set('span.parent_id', $parentId);
431431

432-
$this->assertEquals($parentId, $span->get('span.parent_id'));
432+
$this->assertSame($parentId, $span->get('span.parent_id'));
433433
}
434434

435435
public function testAddWithAllScalarTypes(): void
@@ -442,9 +442,9 @@ public function testAddWithAllScalarTypes(): void
442442
Span::add('bool', false);
443443
Span::add('null', null);
444444

445-
$this->assertEquals('value', $span->get('string'));
446-
$this->assertEquals(42, $span->get('int'));
447-
$this->assertEquals(3.14, $span->get('float'));
445+
$this->assertSame('value', $span->get('string'));
446+
$this->assertSame(42, $span->get('int'));
447+
$this->assertSame(3.14, $span->get('float'));
448448
$this->assertFalse($span->get('bool'));
449449
$this->assertNull($span->get('null'));
450450
}
@@ -488,10 +488,10 @@ public function testGetTraceparentReturnsValidFormat(): void
488488

489489
$parts = explode('-', $traceparent);
490490
$this->assertCount(4, $parts);
491-
$this->assertEquals('00', $parts[0]);
492-
$this->assertEquals(32, strlen($parts[1]));
493-
$this->assertEquals(16, strlen($parts[2]));
494-
$this->assertEquals('01', $parts[3]);
491+
$this->assertSame('00', $parts[0]);
492+
$this->assertSame(32, strlen($parts[1]));
493+
$this->assertSame(16, strlen($parts[2]));
494+
$this->assertSame('01', $parts[3]);
495495
}
496496

497497
public function testGetTraceparentUsesSpanAttributes(): void
@@ -502,7 +502,7 @@ public function testGetTraceparentUsesSpanAttributes(): void
502502

503503
$traceparent = $span->getTraceparent();
504504

505-
$this->assertEquals("00-{$traceId}-{$spanId}-01", $traceparent);
505+
$this->assertSame("00-{$traceId}-{$spanId}-01", $traceparent);
506506
}
507507

508508
public function testTraceparentRoundTrip(): void
@@ -512,8 +512,8 @@ public function testTraceparentRoundTrip(): void
512512

513513
$span2 = Span::init($traceparent);
514514

515-
$this->assertEquals($span1->get('span.trace_id'), $span2->get('span.trace_id'));
516-
$this->assertEquals($span1->get('span.id'), $span2->get('span.parent_id'));
515+
$this->assertSame($span1->get('span.trace_id'), $span2->get('span.trace_id'));
516+
$this->assertSame($span1->get('span.id'), $span2->get('span.parent_id'));
517517
}
518518

519519
public function testStaticTraceparentReturnsCurrentSpanTraceparent(): void
@@ -522,7 +522,7 @@ public function testStaticTraceparentReturnsCurrentSpanTraceparent(): void
522522

523523
$traceparent = Span::traceparent();
524524

525-
$this->assertEquals($span->getTraceparent(), $traceparent);
525+
$this->assertSame($span->getTraceparent(), $traceparent);
526526
}
527527

528528
public function testStaticTraceparentReturnsNullWhenNoCurrentSpan(): void
@@ -536,8 +536,8 @@ public function testInitWithTraceparentSetsTraceIdAndParentId(): void
536536

537537
$span = Span::init($traceparent);
538538

539-
$this->assertEquals('0af7651916cd43dd8448eb211c80319c', $span->get('span.trace_id'));
540-
$this->assertEquals('b7ad6b7169203331', $span->get('span.parent_id'));
539+
$this->assertSame('0af7651916cd43dd8448eb211c80319c', $span->get('span.trace_id'));
540+
$this->assertSame('b7ad6b7169203331', $span->get('span.parent_id'));
541541
$this->assertSame($span, Span::current());
542542
}
543543

@@ -547,7 +547,7 @@ public function testInitWithNullTraceparentGeneratesNewTraceId(): void
547547

548548
$traceId = $span->get('span.trace_id');
549549
$this->assertIsString($traceId);
550-
$this->assertEquals(32, strlen($traceId));
550+
$this->assertSame(32, strlen($traceId));
551551
$this->assertNull($span->get('span.parent_id'));
552552
}
553553

@@ -557,7 +557,7 @@ public function testInitWithInvalidTraceparentCreatesNewTrace(): void
557557

558558
$traceId = $span->get('span.trace_id');
559559
$this->assertIsString($traceId);
560-
$this->assertEquals(32, strlen($traceId));
560+
$this->assertSame(32, strlen($traceId));
561561
$this->assertNull($span->get('span.parent_id'));
562562
}
563563

0 commit comments

Comments
 (0)