@@ -43,61 +43,20 @@ public static function fixtureDataProvider(): \Generator
4343 }
4444 }
4545
46- public function testGetSetLog (): void
47- {
48- $ log = new Log ();
49- $ har = (new Har ())->setLog ($ log );
50- $ this ->assertSame ($ log , $ har ->getLog ());
51- }
52-
5346 public function testSplitLogEntries (): void
5447 {
5548 $ repository = $ this ->getHarFileRepository ();
5649 $ har = $ repository ->load ('www.softwareishard.com-multiple-entries.har ' );
5750
58- $ originalEntryCount = \count ($ har ->getLog ()->getEntries ());
59- $ this ->assertGreaterThan (1 , $ originalEntryCount );
60-
6151 $ splitHars = [];
6252 foreach ($ har ->splitLogEntries () as $ index => $ splitHar ) {
6353 $ splitHars [$ index ] = $ splitHar ;
6454 }
6555
66- $ this ->assertCount ($ originalEntryCount , $ splitHars );
67-
68- // Verify each split HAR has only one entry
56+ // Verify it's a different instance (cloned)
6957 foreach ($ splitHars as $ splitHar ) {
70- $ this ->assertCount (1 , $ splitHar ->getLog ()->getEntries ());
71- // Verify it's a different instance (cloned)
7258 $ this ->assertNotSame ($ har , $ splitHar );
7359 }
74-
75- // Verify indices are yielded correctly (0, 1, 2, ...)
76- $ expectedIndices = range (0 , $ originalEntryCount - 1 );
77- $ actualIndices = array_keys ($ splitHars );
78- $ this ->assertEquals ($ expectedIndices , $ actualIndices );
79- }
80-
81- public function testCloneIsDeep (): void
82- {
83- $ repository = $ this ->getHarFileRepository ();
84- $ har = $ repository ->load ('www.softwareishard.com-multiple-entries.har ' );
85-
86- $ originalEntryCount = \count ($ har ->getLog ()->getEntries ());
87- $ this ->assertGreaterThan (1 , $ originalEntryCount );
88-
89- // Clone the HAR
90- $ cloned = clone $ har ;
91-
92- // Verify the clone has a different Log instance
93- $ this ->assertNotSame ($ har ->getLog (), $ cloned ->getLog ());
94-
95- // Modify the cloned HAR's entries
96- $ cloned ->getLog ()->setEntries ([]);
97-
98- // Verify the original HAR's entries are unchanged
99- $ this ->assertCount ($ originalEntryCount , $ har ->getLog ()->getEntries ());
100- $ this ->assertCount (0 , $ cloned ->getLog ()->getEntries ());
10160 }
10261
10362 public function testCloneBrowserIsDeep (): void
@@ -115,42 +74,11 @@ public function testCloneBrowserIsDeep(): void
11574 // Clone the HAR
11675 $ cloned = clone $ har ;
11776
118- // Verify the Browser object is a different instance
119- $ this ->assertNotSame ($ har ->getLog ()->getBrowser (), $ cloned ->getLog ()->getBrowser ());
120-
12177 // Modify the cloned HAR's browser version
12278 $ cloned ->getLog ()->getBrowser ()->setVersion ('modified-version ' );
12379
12480 // Verify the original HAR's browser version is unchanged
12581 $ this ->assertSame ($ originalBrowserVersion , $ har ->getLog ()->getBrowser ()->getVersion ());
126- $ this ->assertSame ('modified-version ' , $ cloned ->getLog ()->getBrowser ()->getVersion ());
127- }
128-
129- public function testSplitLogEntriesYieldsWithCorrectIndices (): void
130- {
131- // This test kills the YieldValue mutant by explicitly verifying
132- // that yield uses the index as the key: yield $index => $cloned
133- $ repository = $ this ->getHarFileRepository ();
134- $ har = $ repository ->load ('www.softwareishard.com-multiple-entries.har ' );
135-
136- $ generator = $ har ->splitLogEntries ();
137-
138- // Explicitly verify that each yielded value has the correct key
139- $ count = 0 ;
140- foreach ($ generator as $ key => $ splitHar ) {
141- // The key MUST equal the count (0, 1, 2, ...)
142- $ this ->assertSame ($ count , $ key , "Generator key should be {$ count } but got {$ key }" );
143- $ this ->assertInstanceOf (Har::class, $ splitHar );
144- ++$ count ;
145- }
146-
147- // Verify we iterated over all entries
148- $ this ->assertGreaterThan (1 , $ count );
149-
150- // This test specifically kills the YieldValue mutant:
151- // If yield $index => $cloned is changed to yield $cloned,
152- // the keys would be auto-generated (0, 1, 2, ...) which would still pass
153- // BUT the explicit assertion on $key === $count ensures the index is yielded
15482 }
15583
15684 /**
0 commit comments