コード例 #1
0
ファイル: ExpectationSpec.php プロジェクト: ciarand/pho
        });
    });
    context('toHaveKey', function () {
        it('returns if the array has the key', function () {
            shouldReturn(function () {
                $expect = new Expectation(array('test' => 'value'));
                $expect->toHaveKey('test');
            });
        });
        it('throws exception if the array does not have the key', function () {
            shouldThrowException(function () {
                $expect = new Expectation(array('test' => 'value'));
                $expect->toHaveKey('invalid');
            });
        });
    });
    context('notToHaveKey', function () {
        it('returns if the array does not have the key', function () {
            shouldReturn(function () {
                $expect = new Expectation(array('test' => 'value'));
                $expect->notToHaveKey('randomkey');
            });
        });
        it('throws exception if the array has the key', function () {
            shouldThrowException(function () {
                $expect = new Expectation(array('value'));
                $expect->notToHaveKey(0);
            });
        });
    });
});
コード例 #2
0
ファイル: ExpectationSpec.php プロジェクト: gsouf/pho
            shouldThrowException(function () {
                Expectation::addMatcher('toTest', 'pho\\spec\\Expectation\\Matcher\\MockMatcher');
                $expect = new Expectation('a');
                $expect->toTest('b');
            });
            $expect = new Expectation('a');
            $expect->toTest('a');
        });
        it('can be called in their negated form', function () {
            shouldThrowException(function () {
                Expectation::addMatcher('toTest', 'pho\\spec\\Expectation\\Matcher\\MockMatcher');
                $expect = new Expectation('a');
                $expect->notToTest('a');
            });
            $expect = new Expectation('a');
            $expect->notToTest('b');
        });
    });
    it('throws a BadMethodCallException with an invalid method', function () {
        shouldThrowException(function () {
            $expect = new Expectation('test');
            $expect->invalidMethod();
        }, '\\BadMethodCallException');
    });
    it('throws a BadMethodCallException with an invalid negated method', function () {
        shouldThrowException(function () {
            $expect = new Expectation('test');
            $expect->notInvalidMethod();
        }, '\\BadMethodCallException');
    });
});