コード例 #1
0
ファイル: SystemWriterSpec.php プロジェクト: Hexmedia/Crontab
 function it_is_initializable()
 {
     if (Unix::isUnix()) {
         //Currently this will work only on *nix
         $this->shouldHaveType('Hexmedia\\Crontab\\Writer\\SystemWriter');
     }
 }
コード例 #2
0
 function it_is_able_to_create_writer(Crontab $crontab)
 {
     $this->isSystemSupported();
     $created = $this::create($crontab);
     $created->shouldImplement('Hexmedia\\Crontab\\Writer\\System\\WriterInterface');
     if (true === Unix::isUnix()) {
         $created->shouldImplement('Hexmedia\\Crontab\\Writer\\System\\UnixWriter');
     }
 }
コード例 #3
0
 function it_is_throwing_when_there_is_no_parser()
 {
     $wasUnix = false;
     if (true === Unix::isUnix()) {
         $wasUnix = true;
         Unix::removeUnix(PHP_OS);
     }
     $this->clearParser()->shouldReturn($this);
     $this->getParsers()->shouldHaveCount(0);
     $this->shouldThrow(new NoSupportedParserException(sprintf('There is no supported parser for this type or operating system (your is "%s").', PHP_OS)))->duringCreate('some text', '/tmp/file');
     if ($wasUnix) {
         Unix::addUnix(PHP_OS);
     }
 }
コード例 #4
0
ファイル: UnixSystemReader.php プロジェクト: Hexmedia/Crontab
 /**
  * @return string
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 protected function getContent()
 {
     $result = Unix::get($this->user);
     return $result;
 }
コード例 #5
0
ファイル: UnixParser.php プロジェクト: Hexmedia/Crontab
 /**
  * @return bool
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public static function isSupported()
 {
     return Unix::isUnix();
 }
コード例 #6
0
 protected function isSystemSupported()
 {
     if (false === Unix::isUnix()) {
         throw new SkippingException(sprintf('Your os "%s" is currently not supported.', PHP_OS));
     }
 }
コード例 #7
0
ファイル: UnixWriterSpec.php プロジェクト: Hexmedia/Crontab
 function it_allows_to_write($crontab)
 {
     $processBuilder = new FakeProcessBuilder();
     $shouldBe = $this->defaultContent;
     $processBuilder->addCommand("'crontab' '(/var)?/tmp/.*'", function ($command) use($shouldBe) {
         if (preg_match("#'crontab' '((/var)?/tmp/.*)'#", $command, $matches)) {
             $content = file_get_contents($matches[1]);
             if ($content !== $shouldBe) {
                 throw new FailureException("Content in not correct");
             }
         }
     }, 1);
     Unix::setProcessBuilder($processBuilder);
     $this->write($crontab)->shouldReturn(true);
     Unix::setProcessBuilder(null);
 }
コード例 #8
0
ファイル: UnixWriter.php プロジェクト: Hexmedia/Crontab
 /**
  * @param string $content
  *
  * @return bool
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 protected function saveCrontab($content)
 {
     Unix::save($content);
     return true;
 }
コード例 #9
0
 /**
  * @Given The process builder is fake
  *
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public function theProcessBuilderIsFake()
 {
     $this->processBuilder = new FakeProcessBuilder();
     Unix::setProcessBuilder($this->processBuilder);
 }