示例#1
0
 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();
 }
示例#2
0
 /**
  * @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);
     });
 }
示例#3
0
 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);
 }
示例#4
0
 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());
 }
示例#6
0
 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));
 }
示例#7
0
 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');
 }
示例#8
0
 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;
 }
示例#9
0
 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");
     }
 }
示例#10
0
 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');
 }
示例#11
0
 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'));
 }
示例#12
0
 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']);
 }
示例#13
0
 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);
 }
示例#14
0
 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' => '*****@*****.**'));
 }
示例#15
0
 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;
 }
示例#16
0
 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));
     }
 }
示例#17
0
 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' => '*****@*****.**'));
 }
示例#18
0
 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');
 }
示例#19
0
 /**
  * {@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']);
     }
 }
示例#20
0
 public function setUp()
 {
     $this->module = new \Codeception\Module\FTP(make_container());
     $this->module->_setConfig($this->config);
     $this->module->_before(Stub::make('\\Codeception\\TestCase'));
 }
示例#21
0
 public function setUp()
 {
     $this->module = new \Codeception\Module\PhpSiteHelper(make_container());
 }
示例#22
0
 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();
 }
示例#24
0
 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());
 }