Example #1
0
 /**
  * check loading with null input
  *
  * @return void
  */
 public function testLoadDir()
 {
     $dir = __DIR__;
     $sut = new ScanStrategy();
     $sut->setScanDir($dir);
     $this->assertTrue($sut->supports(null));
     $this->assertEquals([file_get_contents($dir . '/resources/definition/test1.json'), file_get_contents($dir . '/resources/definition/test2.json')], $sut->load($dir));
 }
 /**
  * check loading with null input
  *
  * @return void
  */
 public function testLoadDir()
 {
     $file = __DIR__ . '/resources/definition/test.json';
     $serializer = $this->getMockBuilder('Jms\\Serializer\\SerializerInterface')->disableOriginalConstructor()->setMethods(['serialize', 'deserialize'])->getMock();
     $serializer->expects($this->once())->method('deserialize')->with(file_get_contents($file), 'Graviton\\GeneratorBundle\\Definition\\Schema\\Definition', 'json')->will($this->returnValue((new Definition())->setId('a')));
     $sut = new ScanStrategy($serializer);
     $sut->setScanDir(__DIR__);
     $this->assertTrue($sut->supports(null));
     $data = $sut->load(null);
     $this->assertContainsOnlyInstancesOf('Graviton\\GeneratorBundle\\Definition\\JsonDefinition', $data);
     $this->assertEquals($data, [new JsonDefinition((new Definition())->setId('a'))]);
 }