Пример #1
0
 /**
  * test loading multiple files from dir
  *
  * @return void
  */
 public function testLoadDir()
 {
     $dir = __DIR__ . '/resources/definition';
     $sut = new DirStrategy();
     $this->assertTrue($sut->supports($dir));
     $this->assertEquals([file_get_contents($dir . '/test1.json'), file_get_contents($dir . '/test2.json')], $sut->load($dir));
 }
Пример #2
0
 /**
  * test loading multiple files from dir
  *
  * @return void
  */
 public function testLoadDir()
 {
     $dir = __DIR__ . '/dir';
     $serializer = $this->getMockBuilder('Jms\\Serializer\\SerializerInterface')->disableOriginalConstructor()->setMethods(['serialize', 'deserialize'])->getMock();
     $serializer->expects($this->exactly(2))->method('deserialize')->withConsecutive([file_get_contents($dir . '/test1.json'), 'Graviton\\GeneratorBundle\\Definition\\Schema\\Definition', 'json'], [file_get_contents($dir . '/test2.json'), 'Graviton\\GeneratorBundle\\Definition\\Schema\\Definition', 'json'])->will($this->onConsecutiveCalls((new Definition())->setId('a'), (new Definition())->setId('b')));
     $sut = new DirStrategy($serializer);
     $this->assertTrue($sut->supports($dir));
     $data = $sut->load($dir);
     $this->assertContainsOnlyInstancesOf('Graviton\\GeneratorBundle\\Definition\\JsonDefinition', $data);
     $this->assertEquals($data, [new JsonDefinition((new Definition())->setId('a')), new JsonDefinition((new Definition())->setId('b'))]);
 }