public function testWorkflow()
 {
     // generate file with own public key for the sake of decrypting in ReceiverTest
     $zip = __DIR__ . "/data/testMocked_self.zip";
     $fdot = new FatcaDataOecdTest();
     $fdot->setUp();
     $fdot->conMan->config["FatcaIrsPublic"] = $fdot->conMan->config["FatcaKeyPublic"];
     if (false) {
         // generate zip file and save
         $ts1 = strtotime("2010-10-05 04:03:02");
         $ts2 = strftime("%Y-%m-%dT%H:%M:%S", $ts1);
         $fdot->oecd->MessageSpec->Timestamp = $ts2;
         // set sender GIIN as in config
         $fdot->oecd->MessageSpec->SendingCompanyIN = $fdot->conMan->config["ffaid"];
         $fdo = new FatcaDataOecd($fdot->oecd);
         $tmtr = Transmitter::shortcut($fdo, "html", "", $fdot->conMan->config);
         copy($tmtr->tf4, $zip);
     }
     $rx = Receiver::shortcut($fdot->conMan->config, $zip);
     $this->assertEquals("CBC", $rx->rm->am->algoS);
     $this->assertEquals(256, strlen($rx->rm->aesEncrypted));
     $this->assertEquals("amfWen1oChoLGXU8Qk+Ad80b9a7Dn53B1lFqVxELoKOd7vuTZYvtLlkjqmpgzyrc/cpuqdTDxAtpWIyMjXc1D07wK7CMpzhM0MemG+74D1M1zL5MhWME8mz0s+ninYjaeahhohV6iQVlnZ61axs8RPHtow0duP1QyRJiZSPE1qe4p9m2eoCqvsU4VczxSOiXgqppiYbW1SW0I0lj69UWEjlnCRr8FT83DRVExoAx39mPvIf5M7R+SEOjxv2+AhyaMOZmNDU4lRzUxGmM7KviGwXy8k2ZW1p6jjPid0ga109LvSvBAHPzPhLgyAUBmJCQtSOzvC+zMBnSCfG8DtjZ1A==", base64_encode($rx->rm->aesEncrypted));
     $this->assertEquals(48, strlen($rx->rm->am->getAesIv()));
     $this->assertEquals("tnFoqXIhAQ3V8+NomTb593QC1hN8IbAVCm7VQ3f5sH24fGO9oDRz7jG9lfZRhvTX", base64_encode($rx->rm->am->getAesIv()));
     //    echo "From: ".$rx->rm->from."\n";
     //    echo "To: ".$rx->rm->to."\n";
     //    //echo "Payload encrypted: ".$rx->dataEncrypted."\n";
     //    //echo "Payload decrypted: ".$rx->dataCompressed."\n";
     //    echo "Payload uncompressed: ".$rx->dataXmlSigned."\n";
     $this->assertTrue(!!$rx->dataXmlSigned);
 }
 public function testMocked()
 {
     $fdat = new FatcaDataArrayTest();
     $fdat->setUp();
     # instead of mocking this simple class, just use it directly and replace its generated IDs
     $guidMan = new \FatcaIdesPhp\GuidManager();
     $guidMan->guidPrepd = range(1, count($guidMan->guidPrepd));
     $ts1 = strtotime("2010-10-05 04:03:02");
     $ts2 = strftime("%Y-%m-%dT%H:%M:%S", $ts1);
     $fda = new FatcaDataArray($fdat->di, false, "", 2014, $fdat->conMan, $guidMan);
     $fda->ts = $ts1;
     $fdot = new FatcaDataOecdTest();
     $fdot->setUp();
     $fdot->oecd->MessageSpec->Timestamp = $ts2;
     // no need to pass in GuidManager here because the dummy fixture doesnt use a random DocRefId field
     $fdo = new FatcaDataOecd($fdot->oecd);
     $input = array("array" => $fda, "oecd" => $fdo);
     foreach ($input as $k => $v) {
         $tmtr = Transmitter::shortcut($v, "html", "", $fdat->conMan->config);
         $expected = __DIR__ . "/data/testMocked_{$k}_payload_unsigned.xml";
         # file_put_contents($expected,$tmtr->dataXml);
         $this->assertXmlStringEqualsXmlFile($expected, $tmtr->dataXml);
         # The below will fail because I do not inject the signing manager
         # signed xml
         # $expected=__DIR__."/data/testMocked_${k}_payload_signed.xml";
         # # file_put_contents($expected,$tmtr->dataXmlSigned);
         # $this->assertXmlStringEqualsXmlFile(
         #   $expected,
         #   $tmtr->dataXmlSigned);
         # zip file
         # $expected=__DIR__."/data/testMocked_$k.zip";
         # # copy($tmtr->tf4,$expected);
         # $this->assertEquals(md5_file($tmtr->tf4),md5_file($expected));
     }
 }