function testGetTestLabel() { $foo = new GeneratedTestClass(); file_put_contents(LIMB_VAR_DIR . '/foo.php', $foo->generate()); $node = new lmbTestTreeFileNode(LIMB_VAR_DIR . '/foo.php'); $this->assertEqual($node->getTestLabel(), 'foo.php'); $group = $node->createTestCase(); $this->assertEqual($group->getLabel(), 'foo.php'); }
function testNotAGlobMatch() { mkdir(LIMB_VAR_DIR . '/a'); $test1 = new GeneratedTestClass(); $test2 = new GeneratedTestClass(); file_put_contents(LIMB_VAR_DIR . '/a/bar_test.php', $test1->generate()); file_put_contents(LIMB_VAR_DIR . '/a/foo_test.php', $test2->generate()); $root_node = new lmbTestTreeGlobNode(LIMB_VAR_DIR . '/a'); $this->_runNodeAndAssertOutput($root_node, $test1->getOutput() . $test2->getOutput()); }
protected function _testCodeInAdapter($code, $pass, $fail_message = null) { $test = new GeneratedTestClass(); $test->setParentClass('lmbPHPUnitTestCase'); $test_file = LIMB_VAR_DIR . '/' . uniqid() . '.php'; file_put_contents($test_file, $test->generate($code)); $group = new lmbTestGroup(); $group->addFile($test_file); $group->run($reporter = new lmbTestReporter()); $this->assertEqual($pass, $reporter->getStatus()); if (!$pass && $fail_message) { $this->assertPattern('/' . $fail_message . '/', $reporter->getOutput(), 'Wrong error message'); } return $reporter->getOutput(); }
function testParentFixturesAreExecuted() { mkdir($this->var_dir . '/a'); mkdir($this->var_dir . '/a/b'); file_put_contents($this->var_dir . '/a/.setup.php', '<?php echo "setup"; ?>'); file_put_contents($this->var_dir . '/a/.teardown.php', '<?php echo "teardown"; ?>'); file_put_contents($this->var_dir . '/a/b/.setup.php', '<?php echo "setup2"; ?>'); file_put_contents($this->var_dir . '/a/b/.teardown.php', '<?php echo "teardown2"; ?>'); $test1 = new GeneratedTestClass(); $test2 = new GeneratedTestClass(); file_put_contents($this->var_dir . '/a/b/bar_test.php', $test1->generate()); file_put_contents($this->var_dir . '/a/b/foo_test.php', $test2->generate()); $node = new lmbTestTreeFilePathNode($this->var_dir . '/a', -1); $child = $node->findChildByPath('/0/0/1'); $this->_runNodeAndAssertOutput($child, "setupsetup2" . $test2->getOutput() . "teardown2teardown"); }