Exemple #1
0
 /**
  * Ran before the containing test suite is invoked.
  *
  * @param Suite $suite The test suite before which to run this method
  */
 public function beforeSuite(Suite $suite)
 {
     if ($this->depth == 0) {
         $this->console->writeLn('');
     }
     $leftPad = str_repeat(' ', self::TAB_SIZE * $this->depth);
     $title = $suite->getTitle();
     $this->console->writeLn($leftPad . $title);
     $this->depth += 1;
 }
Exemple #2
0
 /**
  * Runs the afterEach hooks of the given suite and its parent suites
  * recursively. They are ran in the order in the opposite order, from inner
  * suites to outer suites.
  *
  * @param Suite $suite The suite with the hooks to run
  */
 private function runAfterEachHooks(Suite $suite)
 {
     $this->runRunnable($suite->getHook('afterEach'));
     if ($suite->getParent()) {
         $this->runAfterEachHooks($suite->getParent());
     }
 }
Exemple #3
0
 /**
  * Adds a suite to the list of nested suites.
  *
  * @param Suite $suite The suite to add
  */
 public function addSuite($suite)
 {
     if (true === $this->pending) {
         $suite->setPending();
     }
     $this->suites[] = $suite;
 }
 public function afterSuite(Suite $suite)
 {
     $this->console->writeLn("##teamcity[testSuiteFinished name='" . $suite->getTitle() . "' duration='" . $this->getDurationTime(md5($suite->getTitle())) . "']");
     array_pop($this->depth);
     return parent::beforeSuite($suite);
 }
Exemple #5
0
<?php

use pho\Suite\Suite;
describe('Suite', function () {
    $parent = new Suite('Parent', function () {
    });
    $child = new Suite('Child', function () {
    }, $parent);
    context('__toString', function () use($child, $parent) {
        it('returns the title if no parent exists', function () use($parent) {
            expect((string) $parent)->toEqual('Parent');
        });
        it('is preceded by the parent title, if set', function () use($child) {
            expect((string) $child)->toEqual('Parent Child');
        });
    });
    context('__set', function () use($child, $parent) {
        it('sets a key value pair for the given suite', function () use($parent) {
            $parent->key1 = 'parentValue';
            expect($parent->key1)->toEqual('parentValue');
        });
        it('does not modify the parent suite', function () use($parent, $child) {
            $parent->key2 = 'parentValue';
            $child->key2 = 'childValue';
            expect($child->key2)->toEqual('childValue');
            expect($parent->key2)->toEqual('parentValue');
        });
        it('throws an exception if it conflicts with a method', function () use($child) {
            $overwriteAttempt = function () {
                $this->addSpec = 'should fail';
            };