示例#1
0
 /**
  * @test
  */
 public function adds_jobs()
 {
     $backup = new Backup($this->dropboxInstance(), $this->working);
     $backup->addJob(new Job(new MySQLDatabase(['host' => 'foo', 'name' => 'bar', 'user' => 'abc', 'password' => 'password']), 'database'));
     $backup->addJob(new Job(new PostgreSQLDatabase(['host' => 'foo', 'name' => 'bar', 'user' => 'abc', 'password' => 'password']), 'database'));
     $backup->addJob(new Job(new File($this->css_file(), $this->css_directory())));
     $backup->addJob(new Job(new Directory($this->css_components_directory(), $this->css_directory())));
     $jobs = $backup->getJobs();
     $this->assertEquals(4, count($jobs), 'Number of jobs does not equal 4');
     $this->assertEquals('database', $jobs[0]->namespace, 'MySQLDatabase job namespace is not set to "database"');
     $this->assertInstanceOf(MySQLDatabase::class, $jobs[0]->job, 'Job is not instance of MySQLDatabase');
     $this->assertInstanceOf(PostgreSQLDatabase::class, $jobs[1]->job, 'Job is not instance of PostgreSQLDatabase');
     $this->assertEmpty($jobs[2]->namespace, 'File job namespace is not empty');
     $this->assertInstanceOf(File::class, $jobs[2]->job, 'Job is not instance of File');
     $this->assertEmpty($jobs[3]->namespace, 'Directory job namespace is not empty');
     $this->assertInstanceOf(Directory::class, $jobs[3]->job, 'Job is not instance of Directory');
 }