예제 #1
0
 /**
  * check if loading from a single file works
  *
  * @return void
  */
 public function testLoadReturnsSingleFileArray()
 {
     $file = __DIR__ . '/resources/definition/test1.json';
     $sut = new FileStrategy();
     $this->assertTrue($sut->supports($file));
     $this->assertEquals([file_get_contents($file)], $sut->load($file));
 }
예제 #2
0
 /**
  * check if loading from a single file works
  *
  * @return void
  */
 public function testLoadReturnsSingleFileArray()
 {
     $file = __DIR__ . '/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 FileStrategy($serializer);
     $this->assertTrue($sut->supports($file));
     $data = $sut->load($file);
     $this->assertContainsOnlyInstancesOf('Graviton\\GeneratorBundle\\Definition\\JsonDefinition', $data);
     $this->assertEquals($data, [new JsonDefinition((new Definition())->setId('a'))]);
 }