Exemple #1
0
 /**
  * Constructor
  *
  * @param string $name
  * @param function $fn
  */
 public function __construct($name, $fn)
 {
     $this->fn = $fn;
     $this->name = $name;
     if (!Preview::is_php53()) {
         $ref = new \ReflectionFunction($fn);
         $this->fn = $ref->getClosure();
     }
 }
Exemple #2
0
<?php

namespace Preview\DSL\BDD;

use Preview\Preview;
require_once 'ok.php';
// for php 5.3
if (Preview::is_php53()) {
    describe("array_pop", function () {
        subject(array(0, 1, 2, 3));
        it("should return the last item", function ($self) {
            $end = end($self->subject);
            ok(array_pop($self->subject) == $end);
        });
        it("should remove the last item from original array", function ($self) {
            array_pop($self->subject);
            ok($self->subject == array(0, 1, 2));
        });
    });
    // for php 5.4 and above
} else {
    describe("array_pop", function () {
        subject(array(0, 1, 2, 3));
        it("should return the last item", function () {
            $end = end($this->subject);
            ok(array_pop($this->subject) == $end);
        });
        it("should remove the last item from original array", function () {
            array_pop($this->subject);
            ok($this->subject == array(0, 1, 2));
        });
Exemple #3
0
 /**
  * constructor
  *
  * @param string $title
  * @param function $fn
  */
 public function __construct($title, $fn)
 {
     $this->context = new \stdClass();
     $this->title = $title;
     $this->pending = !isset($fn);
     $this->timer = new Timer();
     $this->fn = $fn;
     if ($fn) {
         $ref = new \ReflectionFunction($fn);
         $this->filename = $ref->getFileName();
         $this->startline = $ref->getStartLine();
         $this->endline = $ref->getEndLine();
         if (!Preview::is_php53()) {
             $this->fn = $ref->getClosure();
         }
     }
 }