Пример #1
0
 public function setUp()
 {
     $files = \Fuel\Core\File::read_dir(APPPATH . 'tests/files', 1);
     foreach ($files as $file => $val) {
         \Fuel\Core\File::delete_dir(APPPATH . 'tests/files' . DS . $file);
     }
     $this->pass = Model_Pass::forge(array('name' => 'test name', 'description' => 'desc', 'logo_text' => 'sample', 'barcode_message' => 'message', 'barcode_format' => 0, 'offer_label' => 'samaplelabel', 'offer_value' => 'samplevalue'));
     $this->pass->save();
     \Fuel\Core\Config::set('pass.files_dir', APPPATH . 'tests/files');
     $this->path = \Fuel\Core\Config::get('pass.files_dir');
     $this->manager = new Pass_File_Manager($this->pass);
     \Fuel\Core\File::copy(APPPATH . 'tests/certificate.p12', $this->manager->file_path('certificate.p12'));
 }
 public function test_generate_zip()
 {
     $manager = new Pass_File_Manager($this->pass);
     \Fuel\Core\File::copy(APPPATH . 'tests/certificate.p12', $manager->file_path('certificate.p12'));
     $cert_password = '';
     $manager->generate_file('pass.json', $this->pass->pass_json());
     $manager->generate_file('manifest.json', $this->pass->manifest($manager->files()));
     $cert = new Certificate($manager->file_path('certificate.p12'));
     $signature = $cert->signature($manager->file_path('manifest.json'), $manager->file_path('signature'));
     $manager->generate_file('signature', $signature);
     $this->assertTrue($manager->generate_zip());
     $this->assertFileExists($manager->pkpass_path());
 }