Skip to content

Commit aab96d5

Browse files
committed
Fix tests
1 parent 553697e commit aab96d5

File tree

1 file changed

+84
-11
lines changed

1 file changed

+84
-11
lines changed

tests/DotTest.php

Lines changed: 84 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public function testAddKeyValuePair()
7979
$dot->add('foo.bar', 'baz');
8080

8181
$this->assertEquals('baz', $dot->get('foo.bar'));
82-
$this->assertInstanceOf(Dot::class, $dot);
8382
}
8483

8584
public function testAddValueToExistingKey()
@@ -101,6 +100,13 @@ public function testAddArrayOfKeyValuePairs()
101100
$this->assertSame(['foobar' => 'baz', 'corge' => 'grault'], $dot->all());
102101
}
103102

103+
public function testAddReturnsDot()
104+
{
105+
$dot = new Dot;
106+
107+
$this->assertInstanceOf(Dot::class, $dot->add('foo', 'bar'));
108+
}
109+
104110
/*
105111
* --------------------------------------------------------------
106112
* All
@@ -126,7 +132,6 @@ public function testClearKey()
126132
$dot->clear('foo.bar');
127133

128134
$this->assertSame([], $dot->get('foo.bar'));
129-
$this->assertInstanceOf(Dot::class, $dot);
130135
}
131136

132137
public function testClearNonExistingKey()
@@ -153,6 +158,13 @@ public function testClearAll()
153158
$this->assertSame([], $dot->all());
154159
}
155160

161+
public function testClearReturnsDot()
162+
{
163+
$dot = new Dot();
164+
165+
$this->assertInstanceOf(Dot::class, $dot->clear());
166+
}
167+
156168
/*
157169
* --------------------------------------------------------------
158170
* Delete
@@ -165,7 +177,6 @@ public function testDeleteKey()
165177
$dot->delete('foo.bar');
166178

167179
$this->assertFalse($dot->has('foo.bar'));
168-
$this->assertInstanceOf(Dot::class, $dot);
169180
}
170181

171182
public function testDeleteNonExistingKey()
@@ -184,6 +195,13 @@ public function testDeleteArrayOfKeys()
184195
$this->assertSame([], $dot->all());
185196
}
186197

198+
public function testDeleteReturnsDot()
199+
{
200+
$dot = new Dot(['foo' => 'bar']);
201+
202+
$this->assertInstanceOf(Dot::class, $dot->clear('foo'));
203+
}
204+
187205
/*
188206
* --------------------------------------------------------------
189207
* Flatten
@@ -318,7 +336,6 @@ public function testMergeArrayWithDot()
318336
$dot->merge(['foo' => ['bar' => 'qux']]);
319337

320338
$this->assertEquals('qux', $dot->get('foo.bar'));
321-
$this->assertInstanceOf(Dot::class, $dot);
322339
}
323340

324341
public function testMergeArrayWithKey()
@@ -347,6 +364,13 @@ public function testMergeDotObjectWithKey()
347364
$this->assertEquals('qux', $dot1->get('foo.bar'));
348365
}
349366

367+
public function testMergeReturnsDot()
368+
{
369+
$dot = new Dot(['foo' => ['bar' => 'baz']]);
370+
371+
$this->assertInstanceOf(Dot::class, $dot->merge(['foo' => ['bar' => 'qux']]));
372+
}
373+
350374
/*
351375
* --------------------------------------------------------------
352376
* Recursive merge
@@ -360,7 +384,6 @@ public function testRecursiveMergeArrayWithDot()
360384

361385
$this->assertEquals(['baz', 'qux'], $dot->get('foo.bar'));
362386
$this->assertEquals('quuz', $dot->get('foo.quux'));
363-
$this->assertInstanceOf(Dot::class, $dot);
364387
}
365388

366389
public function testRecursiveMergeArrayWithKey()
@@ -392,6 +415,16 @@ public function testRecursiveMergeDotObjectWithKey()
392415
$this->assertEquals('quuz', $dot1->get('foo.quux'));
393416
}
394417

418+
public function testRecursiveMergeReturnsDot()
419+
{
420+
$dot = new Dot(['foo' => ['bar' => 'baz']]);
421+
422+
$this->assertInstanceOf(
423+
Dot::class,
424+
$dot->mergeRecursive(['foo' => ['bar' => 'qux', 'quux' => 'quuz']])
425+
);
426+
}
427+
395428
/*
396429
* --------------------------------------------------------------
397430
* Recursive distinct merge
@@ -405,7 +438,6 @@ public function testRecursiveDistinctMergeArrayWithDot()
405438

406439
$this->assertEquals('qux', $dot->get('foo.bar'));
407440
$this->assertEquals('quuz', $dot->get('foo.quux'));
408-
$this->assertInstanceOf(Dot::class, $dot);
409441
}
410442

411443
public function testRecursiveDistinctMergeArrayWithKey()
@@ -437,6 +469,16 @@ public function testRecursiveDistinctMergeDotObjectWithKey()
437469
$this->assertEquals('quuz', $dot1->get('foo.quux'));
438470
}
439471

472+
public function testRecursivDistincteMergeReturnsDot()
473+
{
474+
$dot = new Dot(['foo' => ['bar' => 'baz']]);
475+
476+
$this->assertInstanceOf(
477+
Dot::class,
478+
$dot->mergeRecursiveDistinct(['foo' => ['bar' => 'qux', 'quux' => 'quuz']])
479+
);
480+
}
481+
440482
/*
441483
* --------------------------------------------------------------
442484
* Pull
@@ -485,7 +527,6 @@ public function testPushValue()
485527
$dot->push('foo');
486528

487529
$this->assertEquals('foo', $dot->get(0));
488-
$this->assertInstanceOf(Dot::class, $dot);
489530
}
490531

491532
public function testPushValueToKey()
@@ -496,6 +537,13 @@ public function testPushValueToKey()
496537
$this->assertSame(['bar', 'baz'], $dot->get('foo'));
497538
}
498539

540+
public function testPushReturnsDot()
541+
{
542+
$dot = $dot = new Dot();
543+
544+
$this->assertInstanceOf(Dot::class, $dot->push('foo'));
545+
}
546+
499547
/*
500548
* --------------------------------------------------------------
501549
* Replace
@@ -508,7 +556,6 @@ public function testReplaceWithArray()
508556
$dot->replace(['foo' => ['qux' => 'quux']]);
509557

510558
$this->assertEquals(['qux' => 'quux'], $dot->get('foo'));
511-
$this->assertInstanceOf(Dot::class, $dot);
512559
}
513560

514561
public function testReplaceKeyWithArray()
@@ -537,6 +584,13 @@ public function testReplaceKeyWithDot()
537584
$this->assertEquals(['bar' => 'baz', 'qux' => 'corge'], $dot1->get('foo'));
538585
}
539586

587+
public function testReplaceReturnsDot()
588+
{
589+
$dot = new Dot(['foo' => ['bar' => 'baz']]);
590+
591+
$this->assertInstanceOf(Dot::class, $dot->replace(['foo' => ['qux' => 'quux']]));
592+
}
593+
540594
/*
541595
* --------------------------------------------------------------
542596
* Set
@@ -549,7 +603,6 @@ public function testSetKeyValuePair()
549603
$dot->set('foo.bar', 'baz');
550604

551605
$this->assertEquals('baz', $dot->get('foo.bar'));
552-
$this->assertInstanceOf(Dot::class, $dot);
553606
}
554607

555608
public function testSetArrayOfKeyValuePairs()
@@ -560,6 +613,13 @@ public function testSetArrayOfKeyValuePairs()
560613
$this->assertSame(['foo' => 'bar', 'baz' => 'qux'], $dot->all());
561614
}
562615

616+
public function testSetReturnsDot()
617+
{
618+
$dot = new Dot();
619+
620+
$this->assertInstanceOf(Dot::class, $dot->set('foo.bar', 'baz'));
621+
}
622+
563623
/*
564624
* --------------------------------------------------------------
565625
* Set array
@@ -572,7 +632,13 @@ public function testSetArray()
572632
$dot->setArray(['foo' => 'bar']);
573633

574634
$this->assertSame(['foo' => 'bar'], $dot->all());
575-
$this->assertInstanceOf(Dot::class, $dot);
635+
}
636+
637+
public function testSetArrayReturnsDot()
638+
{
639+
$dot = new Dot();
640+
641+
$this->assertInstanceOf(Dot::class, $dot->setArray(['foo' => 'bar']));
576642
}
577643

578644
/*
@@ -589,7 +655,14 @@ public function testSetReference()
589655
$dot->set('foo', 'baz');
590656

591657
$this->assertEquals('baz', $items['foo']);
592-
$this->assertInstanceOf(Dot::class, $dot);
658+
}
659+
660+
public function testSetReferenceReturnsDot()
661+
{
662+
$dot = new Dot();
663+
$items = ['foo' => 'bar'];
664+
665+
$this->assertInstanceOf(Dot::class, $dot->setReference($items));
593666
}
594667

595668
/*

0 commit comments

Comments
 (0)