/** * @test * @return Container */ public function setWithValue() { $subject = new Actual(); $subject->push('sample', new Actual('nest')); $this->assertNotNull($subject->sample); return $subject; }
/** * @test * @expectedException \SwaggerAssert\Exception\CompareException */ public function tooManyExpectedKey() { $expected = new Expected(); $expected->push('a'); $expected->push('b'); $expected->push('c'); $actual = new Actual(); $actual->push('a'); $actual->push('b'); $picker = $this->createPickerMock($expected, $actual); $subject = new CompareResponseAndAnnotation($picker); $subject->execute(); }
/** * @test */ public function nestCase() { $expected = new Expected(); $expected->push('a'); $expected->push('b', new Expected('c')); $expected->push('d', new Expected('e', new Expected('f'))); $actual = new Actual(); $actual->push('a'); $actual->push('b', new Actual('c')); $actual->push('d', new Actual('e', new Actual('f'))); $picker = $this->createPickerMock($expected, $actual); $subject = new CompareResponseAndAnnotation($picker); $this->assertTrue($subject->execute()); }
/** * @param array $response * @return Actual */ private function getActualRecursively($response) { $actual = new Actual(); $compress = $this->getCompressed($response); if ($compress !== false) { $collectionActual = new Actual(); foreach ($compress as $compressedVal) { $collectionActual->push($compressedVal); } $actual->push('collection', $collectionActual); return $actual; } foreach ($response as $key => $val) { is_array($val) ? $actual->push($key, $this->getActualRecursively($val)) : $actual->push($key); } return $actual; }