/**
  * @covers \Heystack\Core\DataObjectSchema\SchemaService::addSchema
  */
 public function testCanAddReplaceSchema()
 {
     $schema1 = $this->getMock('Heystack\\Core\\DataObjectSchema\\SchemaInterface');
     $schema2 = $this->getMock('Heystack\\Core\\DataObjectSchema\\SchemaInterface');
     $schema1->expects($this->once())->method('getIdentifier')->will($this->returnValue(new Identifier('test')));
     $schema2->expects($this->once())->method('getIdentifier')->will($this->returnValue(new Identifier('test')));
     $schema1->expects($this->once())->method('getReference')->will($this->returnValue(false));
     $schema2->expects($this->once())->method('getReference')->will($this->returnValue(false));
     $schema1->expects($this->once())->method('mergeSchema')->with($schema2);
     $schemaService = new SchemaService();
     $schemaService->addSchema($schema1);
     $schemaService->addSchema($schema2);
 }
 /**
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::process
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::writeDataObject
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::writeModelAdmin
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::getDataObjectSSViewer
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::getModelAdminSSViewer
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::processFlatStorage
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::processParentStorage
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::processChildStorage
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::isReference
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::beautify
  * @covers \Heystack\Core\DataObjectGenerate\DataObjectGenerator::output
  */
 public function testProcessMakesFiles()
 {
     $referenceSchema = $this->getMock('Heystack\\Core\\DataObjectSchema\\SchemaInterface');
     $this->schemaService->expects($this->once())->method('getSchemas')->will($this->returnValue([$schema = $this->getMock('Heystack\\Core\\DataObjectSchema\\SchemaInterface')]));
     $this->schemaService->expects($this->once())->method('hasSchema')->with('extra')->will($this->returnValue(true));
     $this->schemaService->expects($this->once())->method('getSchema')->with('extra')->will($this->returnValue($referenceSchema));
     $this->buildSchema($schema, 'Test', ['Test' => 'Text', 'Extra' => '+Extra'], [], []);
     $this->buildSchema($referenceSchema, 'Extra', ['Test' => 'Text']);
     ob_start();
     $this->generator->process();
     ob_end_clean();
     $this->assertTrue(file_exists($cachedTestFile = vfsStream::url('root/cache/CachedTest.php')));
     $this->assertTrue(file_exists($storedTestFile = vfsStream::url('root/StoredTest.php')));
     $this->assertTrue(file_exists(vfsStream::url('root/cache/GeneratedModelAdmin.php')));
     $this->assertContains('class CachedTest extends DataObject', file_get_contents($cachedTestFile));
     $this->assertContains('class StoredTest extends CachedTest', file_get_contents($storedTestFile));
 }