public function testLoginToFacebook() { $this->markTestSkipped(); // preconditions: #1 php web server being run $browserModule = new PhpBrowser(make_container()); $browserModule->_setConfig(array('url' => 'http://localhost:8000')); $browserModule->_initialize(); $browserModule->_cleanup(); $browserModule->_before($this->makeTest()); SuiteManager::$modules['PhpBrowser'] = $browserModule; // preconditions: #2 facebook test user was created $this->module->haveFacebookTestUserAccount(); $testUserName = $this->module->grabFacebookTestUserName(); // preconditions: #3 test user logged in on facebook $this->module->haveTestUserLoggedInOnFacebook(); // go to our page with facebook login button $browserModule->amOnPage('/facebook'); // check that yet we are not logged in with facebook $browserModule->see('You are not Connected.'); // click on "Login with Facebook" button to start login with facebook $browserModule->click('Login with Facebook'); // check that we are logged in with facebook $browserModule->see('Your User Object (/me)'); $browserModule->see($testUserName); // cleanup unset(SuiteManager::$modules['PhpBrowser']); $browserModule->_after($this->makeTest()); data::clean(); }
/** * @expectedException PHPUnit_Framework_AssertionFailedError */ public function testExceptionFails() { $module = new \Codeception\Module\Asserts(make_container()); $module->expectException(new Exception('here', 200), function () { throw new Exception('here', 2); }); }
public function testAsserts() { $module = new \Codeception\Module\Asserts(make_container()); $module->assertEquals(1, 1); $module->assertContains(1, [1, 2]); $module->assertSame(1, 1); $module->assertNotSame(1, true); }
public function setUp() { $this->module = new \Codeception\Module\SOAP(make_container()); $this->module->_setConfig(array('schema' => 'http://www.w3.org/2001/xml.xsd', 'endpoint' => 'http://codeception.com/api/wsdl')); $this->layout = \Codeception\Configuration::dataDir() . '/xml/layout.xml'; $this->module->isFunctional = true; $this->module->_before(Stub::makeEmpty('\\Codeception\\Test\\Test')); $this->module->client = Stub::makeEmpty('\\Codeception\\Lib\\Connector\\Universal'); }
public function testCreateSnapshotOnFail() { $module = Stub::construct(get_class($this->module), [make_container()], ['_savePageSource' => Stub::once(function ($filename) { $this->assertEquals(codecept_log_dir('Codeception.Module.UniversalFramework.looks.like..test.fail.html'), $filename); })]); $module->amOnPage('/'); $cest = new \Codeception\Test\Cest($this->module, 'looks:like::test', 'demo1Cest.php'); $module->_failed($cest, new PHPUnit_Framework_AssertionFailedError()); }
public function testSequences() { $module = new \Codeception\Module\Sequence(make_container()); $this->assertNotEquals(sq(), sq()); $this->assertNotEquals(sq(1), sq(2)); $this->assertEquals(sq(1), sq(1)); $old = sq(1); $module->_after($this); $this->assertNotEquals($old, sq(1)); }
public function testAsserts() { $module = new \Codeception\Module\Asserts(make_container()); $module->assertEquals(1, 1); $module->assertContains(1, [1, 2]); $module->assertSame(1, 1); $module->assertNotSame(1, true); $module->assertRegExp('/^[\\d]$/', '1'); $module->assertNotRegExp('/^[a-z]$/', '1'); }
public function setUp() { $this->noPhpWebserver(); $this->noSelenium(); $this->module = new \Codeception\Module\WebDriver(make_container()); $url = 'http://localhost:8000'; $this->module->_setConfig(['url' => $url, 'browser' => 'firefox', 'port' => '4444', 'restart' => true, 'wait' => 0]); $this->module->_initialize(); $this->module->_before($this->makeTest()); $this->webDriver = $this->module->webDriver; }
public function setUp() { $this->module = new \Codeception\Module\Queue(make_container()); $this->module->_setConfig($this->config); $this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase')); try { $this->module->clearQueue('default'); } catch (\Pheanstalk_Exception_ConnectionException $e) { $this->markTestSkipped("Beanstalk is not running"); } }
public function setUp() { $this->module = new \Codeception\Module\AMQP(make_container()); $this->module->_setConfig($this->config); $res = stream_socket_client('tcp://localhost:5672'); if ($res === false) { $this->markTestSkipped('AMQP is not running'); } $this->module->_initialize(); $connection = $this->module->connection; $connection->channel()->queue_declare('queue1'); }
public function setUp() { $this->phpBrowser = new \Codeception\Module\PhpBrowser(make_container()); $url = 'http://localhost:8010'; $this->phpBrowser->_setConfig(array('url' => $url)); $this->phpBrowser->_initialize(); $this->module = Stub::make('\\Codeception\\Module\\REST'); $this->module->_inject($this->phpBrowser); $this->module->_initialize(); $this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest')); $this->phpBrowser->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest')); }
public function setUp() { $connector = new \Codeception\Lib\Connector\Universal(); $connector->setIndex(\Codeception\Configuration::dataDir() . '/rest/index.php'); $connectionModule = new \Codeception\Module\PhpBrowser(make_container()); $this->module = Stub::make('\\Codeception\\Module\\REST'); $this->module->_inject($connectionModule); $this->module->_initialize(); $this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest')); $this->module->client = $connector; $this->module->client->setServerParameters(['SCRIPT_FILENAME' => 'index.php', 'SCRIPT_NAME' => 'index', 'SERVER_NAME' => 'localhost', 'SERVER_PROTOCOL' => 'http']); }
public static function setUpBeforeClass() { self::$module = new \Codeception\Module\Db(make_container()); self::$module->_setConfig(self::$config); self::$module->_initialize(); $sqlite = self::$module->driver; $sqlite->cleanup(); $sql = file_get_contents(\Codeception\Configuration::dataDir() . '/dumps/sqlite.sql'); $sql = preg_replace('%/\\*(?:(?!\\*/).)*\\*/%s', "", $sql); $sql = explode("\n", $sql); $sqlite->load($sql); }
protected function setUp() { if (!class_exists('Mongo')) { $this->markTestSkipped('Mongo is not installed'); } $mongo = new \MongoClient(); $this->module = new MongoDb(make_container()); $this->module->_setConfig($this->mongoConfig); $this->module->_initialize(); $this->db = $mongo->selectDB('test'); $this->userCollection = $this->db->createCollection('users'); $this->userCollection->insert(array('id' => 1, 'email' => '*****@*****.**')); }
public function setUp() { $this->testCase = Stub::make('\\Codeception\\TestCase'); $module = new \Codeception\Module\Dbh(make_container()); try { $driver = Driver::create($this->config['dsn'], $this->config['user'], $this->config['password']); $module::$dbh = $driver->getDbh(); } catch (\PDOException $e) { $this->markTestSkipped('Coudn\'t establish connection to database'); return; } $this->module = $module; }
protected function setUp() { $this->module = new \Codeception\Module\PhpBrowser(make_container()); $url = 'http://localhost:8000'; $this->module->_setConfig(array('url' => $url)); $this->module->_initialize(); $this->module->_cleanup(); $this->module->_before($this->makeTest()); if (class_exists('GuzzleHttp\\Url')) { $this->history = new \GuzzleHttp\Subscriber\History(); $this->module->guzzle->getEmitter()->attach($this->history); } else { $this->module->guzzle->getConfig('handler')->push(\GuzzleHttp\Middleware::history($this->history)); } }
protected function setUp() { if (!class_exists('\\MongoDB\\Client')) { $this->markTestSkipped('MongoDB is not installed'); } $mongo = new \MongoDB\Client(); $this->module = new MongoDb(make_container()); $this->module->_setConfig($this->mongoConfig); try { $this->module->_initialize(); } catch (ModuleException $e) { $this->markTestSkipped($e->getMessage()); } $this->db = $mongo->selectDatabase('test'); $this->userCollection = $this->db->users; $this->userCollection->insertOne(array('id' => 1, 'email' => '*****@*****.**')); }
public function testAsserts() { $module = new \Codeception\Module\Asserts(make_container()); $module->assertEquals(1, 1); $module->assertContains(1, [1, 2]); $module->assertSame(1, 1); $module->assertNotSame(1, true); $module->assertRegExp('/^[\\d]$/', '1'); $module->assertNotRegExp('/^[a-z]$/', '1'); $module->assertEmpty([]); $module->assertNotEmpty([1]); $module->assertNull(null); $module->assertNotNull(''); $module->assertNotNull(false); $module->assertNotNull(0); $module->assertTrue(true); $module->assertFalse(false); $module->assertFileExists(__FILE__); $module->assertFileNotExists(__FILE__ . '.notExist'); }
/** * {@inheritdoc} * * Every time a test starts, cleanup the database and populates it with some * dummy data. */ protected function setUp() { if (!class_exists('Predis\\Client')) { $this->markTestSkipped('Predis is not installed'); } /** @var ModuleContainer $container */ $container = make_container(); try { $this->module = new Redis($container); $this->module->_setConfig(self::$config); $this->module->_initialize(); $this->module->driver->flushDb(); } catch (Predis\Connection\ConnectionException $e) { $this->markTestSkipped($e->getMessage()); } $addMethods = ['string' => 'set', 'list' => 'rPush', 'set' => 'sAdd', 'zset' => 'zAdd', 'hash' => 'hMSet']; foreach (self::$keys as $type => $key) { $this->module->driver->{$addMethods[$type]}($key['name'], $key['value']); } }
public function setUp() { $this->module = new \Codeception\Module\FTP(make_container()); $this->module->_setConfig($this->config); $this->module->_before(Stub::make('\\Codeception\\TestCase')); }
public function setUp() { $this->module = new \Codeception\Module\PhpSiteHelper(make_container()); }
public function setUp() { $this->module = new \Codeception\Module\UniversalFramework(make_container()); }
public function testLoginToFacebook() { if (PHP_MAJOR_VERSION < 7 && getenv('TRAVIS')) { $this->markTestSkipped('run only one thread on Travis'); } // precondition: you need to have a server running for this test // you can start a php server with: php -S 127.0.0.1:8000 -t tests/data/app $browserModule = new PhpBrowser(make_container()); $this->initModule($browserModule, ['url' => 'http://localhost:8000']); $this->module->_inject($browserModule); $this->loginToFacebook($browserModule); // cleanup $browserModule->_after($this->makeTest()); data::clean(); }
public function testCanBeCreatedForModuleObject() { $exception = new \Codeception\Exception\ModuleConfigException(new \Codeception\Module\CodeHelper(make_container()), "Hello world"); $this->assertEquals("CodeHelper module is not configured!\n \nHello world", $exception->getMessage()); }