/** * @test */ public function notContainsValue() { $collection = $this->getCollectionInstance(['fuu', 'bar']); parent::assertFalse($collection->contains('baz')); parent::setExpectedException(KeyIsNotDefinedException::class); $collection->get('baz'); }
public function assert() { $title = $this->webDriver->getTitle(); \PHPUnit_Framework_TestCase::assertNotNull($title); \PHPUnit_Framework_TestCase::assertNotNull($this->title); $title = trim($title); $pos = strpos($title, $this->title); \PHPUnit_Framework_TestCase::assertFalse($pos); }
public function test() { $routerClass = $this->_routerClass; $routerInstance = new $routerClass(); if (!isset($this->_expectModule)) { $this->_expectModule = $routerInstance->getDefaultModuleName(); } if (!isset($this->_expectController)) { $this->_expectController = $routerInstance->getDefaultControllerName(); } if (!isset($this->_expectAction)) { $this->_expectAction = $routerInstance->getDefaultActionName(); } $postfix = ""; if (isset($this->_requiredModule)) { $this->_router->requireModule($this->_requiredModule); if ($this->_requiredModule) { $postfix .= "(module '{$this->_requiredModule}' required)"; } else { $postfix .= '(module required)'; } } if (isset($this->_requiredController)) { $this->_router->requireController($this->_requiredController); if ($this->_requiredController) { $postfix .= "(controller '{$this->_requiredController}' required)"; } else { $postfix .= '(controller required)'; } } if (isset($this->_requiredAction)) { $this->_router->requireAction($this->_requiredAction); if ($this->_requiredAction) { $postfix .= "(action '{$this->_requiredAction}' required)"; } else { $postfix .= '(action required)'; } } $routable = $this->_router->route($this->_uri); if ($this->_isRoutable) { $this->_test->assertTrue($routable, "{$this->_routerClass} router should be able to route '{$this->_uri}' " . $postfix); } else { $this->_test->assertFalse($routable, "{$this->_routerClass} router should not be able to route '{$this->_uri}' " . $postfix); return; } $this->_test->assertEquals($this->_expectModule, $this->_router->getModuleName(), "{$this->_routerClass} routes {$this->_uri} to module '{$this->_expectModule}'"); $this->_test->assertEquals($this->_expectController, $this->_router->getControllerName(), "{$this->_routerClass} routes {$this->_uri} to controller '{$this->_expectController}'"); $this->_test->assertEquals($this->_expectAction, $this->_router->getActionName(), "{$this->_routerClass} routes {$this->_uri} to action '{$this->_expectAction}'"); $this->_test->assertEquals($this->_expectArguments, $this->_router->getActionArguments(), "{$this->_routerClass} gets " . var_export($this->_expectArguments, true) . " from uri '{$this->_uri}'"); }
/** * @return void */ protected function doStrictMethodCheck() { if ($this->isStatic()) { $errMsg = "#{$this->methodName} is an instance method on the class {$this->className}, but you expected it to be static."; } else { $errMsg = "#{$this->methodName} is a static method on the class {$this->className}, but you expected it to be an instance method."; } try { $reflectionMethod = new \ReflectionMethod($this->className, $this->methodName); $this->testCase->assertTrue($reflectionMethod->isStatic() == $this->isStatic(), $errMsg); $this->testCase->assertFalse($reflectionMethod->isPrivate(), "#{$this->methodName} is a private method on {$this->className}, but you cannot mock a private method."); } catch (\ReflectionException $e) { $necessaryMagicMethod = $this->isStatic() ? '__callStatic' : '__call'; $this->testCase->assertTrue(method_exists($this->className, $necessaryMagicMethod), "The method #{$this->methodName} does not exist on the class {$this->className}"); } }
public function it_generates_a_frontend_config_object() { $config = new Config(); $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/application.json'); $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/groups.json'); $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/models.json'); $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/permissions.json'); $this->config = $config; $request = new Request(); $response = new Response(); $route = (object) []; $this->handleFrontendConfigRequest($request, $response, $route)->shouldReturn($this); Assertions::assertEquals('application/json', $response->getHeader('Content-Type'), 'should set content type to JSON'); Assertions::assertEquals('BackbonePHP', $response->getBody()->appName, 'should set status field'); Assertions::assertFalse(isset($response->getBody()->groups), 'should net expose user groups'); Assertions::assertFalse(isset($response->getBody()->permissions), 'should net expose permissions'); }
/** * Assert class exist. * * @param string $class */ protected static function assertClassDoesNotExist($class) { $classIncluded = class_exists($class); parent::assertFalse($classIncluded); }
public function assert() { $this->getTestCase()->assertElementExists($this->selector, $this->by); \PHPUnit_Framework_TestCase::assertFalse($this->webDriver->{$this->by}($this->selector)->isDisplayed(), sprintf('The element: %s, is displayed and it should not have been', $this->selector)); }
/** * @deprecated since 2.3 * @static * @param mixed $actual * @param string $messages * @return void */ public static function assertFalse($actual, $messages = '') { parent::assertFalse((bool) $actual, $messages); }
static function assertFalse($actual, $string = '') { parent::assertFalse((bool) $actual, $string); }
/** * Checks an element doesn't have a class * * @Then /^"([^"]*)" element should not have class "([^"]*)"$/ * * @return void */ public function elementShouldNotHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "' . $selector . '"'); } \PHPUnit_Framework_TestCase::assertFalse($element->hasClass($class)); }
/** * Create an additional assertion to ensure the specified class is not * loaded when executing a test * * @param string $className * @param \PHPUnit_Framework_TestCase $test */ private function assertClassNotLoaded($className, \PHPUnit_Framework_TestCase $test) { $test->assertFalse(class_exists($className, false), 'Class ' . $className . ' was loaded during test ' . $this->getCurrentTestName($test)); }
/** * @Then I should not see :arg1 element */ public function iShouldNotSeeElement($locator) { PHPUnit_Framework_TestCase::assertFalse($this->isElemetPresentByXpath($locator), 'can see ' . $locator . ' element on the page'); }