Best Atoum code snippet using stub.getVersions
class.addonmodel.php
Source:class.addonmodel.php
...281 * @param string|int $Slug The slug to lookup282 * @param bool $GetVersions Whether or not to add an array of versions to the result.283 * @return array284 */285 public function getSlug($slug, $getVersions = false) {286 if (is_numeric($slug)) {287 $addon = $this->getID($slug, false, ['GetVersions' => $getVersions]);288 } else {289 // This is a string identifier for the addon.290 $parts = explode('-', $slug, 3);291 $key = val(0, $parts);292 if (is_numeric($key)) {293 $addon = $this->getID($key, false, ['GetVersions' => $getVersions]);294 } else {295 $type = strtolower(val(1, $parts));296 $typeID = val($type, self::$Types, 0);297 $version = val(2, $parts);298 $addon = $this->getID(array($key, $typeID, $version), false, ['GetVersions' => $getVersions]);299 }300 }301 if (!$addon) {302 return false;303 }304 $addon['Releases'] = [];305 $addon['Prereleases'] = [];306 if ($getVersions) {307 $maxVersion = valr('Versions.0', $addon);308 $foundMax = false;309 $viewingVersion = false;310 if (is_array(val('Versions', $addon))) {311 foreach ($addon['Versions'] as $version) {312 // Find the version we are looking at.313 $versionSlug = AddonModel::slug($addon, $version);314 if ($versionSlug == $slug && $viewingVersion === false) {315 $viewingVersion = $version;316 }317 // Separate releases & prereleases.318 if (AddonModel::isReleaseVersion($version['Version'])) {319 $addon['Releases'][] = $version;320 // Find the latest stable version....
ManagerTest.php
Source:ManagerTest.php
...59 {60 // stub environment61 $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array()));62 $envStub->expects($this->once())63 ->method('getVersions')64 ->will($this->returnValue(array('20120111235330', '20120116183504')));65 $this->manager->setEnvironments(array('mockenv' => $envStub));66 $this->manager->getOutput()->setDecorated(false);67 $return = $this->manager->printStatus('mockenv');68 $this->assertEquals(0, $return);69 rewind($this->manager->getOutput()->getStream());70 $outputStr = stream_get_contents($this->manager->getOutput()->getStream());71 $this->assertRegExp('/up 20120111235330 TestMigration/', $outputStr);72 $this->assertRegExp('/up 20120116183504 TestMigration2/', $outputStr);73 }74 public function testPrintStatusMethodWithNoMigrations()75 {76 // stub environment77 $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array()));78 // override the migrations directory to an empty one79 $configArray = $this->getConfigArray();80 $configArray['paths']['migrations'] = $this->getCorrectedPath(__DIR__ . '/_files/nomigrations');81 $config = new Config($configArray);82 $this->manager->setConfig($config);83 $this->manager->setEnvironments(array('mockenv' => $envStub));84 $this->manager->getOutput()->setDecorated(false);85 $return = $this->manager->printStatus('mockenv');86 $this->assertEquals(0, $return);87 rewind($this->manager->getOutput()->getStream());88 $outputStr = stream_get_contents($this->manager->getOutput()->getStream());89 $this->assertRegExp('/There are no available migrations. Try creating one using the create command./', $outputStr);90 }91 public function testPrintStatusMethodWithMissingMigrations()92 {93 // stub environment94 $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array()));95 $envStub->expects($this->once())96 ->method('getVersions')97 ->will($this->returnValue(array('20120103083300', '20120815145812')));98 $this->manager->setEnvironments(array('mockenv' => $envStub));99 $this->manager->getOutput()->setDecorated(false);100 $return = $this->manager->printStatus('mockenv');101 $this->assertEquals(Manager::EXIT_STATUS_MISSING, $return);102 rewind($this->manager->getOutput()->getStream());103 $outputStr = stream_get_contents($this->manager->getOutput()->getStream());104 $this->assertRegExp('/up 20120103083300 \*\* MISSING \*\*/', $outputStr);105 $this->assertRegExp('/up 20120815145812 \*\* MISSING \*\*/', $outputStr);106 }107 public function testPrintStatusMethodWithDownMigrations()108 {109 // stub environment110 $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array()));111 $envStub->expects($this->once())112 ->method('getVersions')113 ->will($this->returnValue(array('20120111235330')));114 $this->manager->setEnvironments(array('mockenv' => $envStub));115 $return = $this->manager->printStatus('mockenv');116 $this->assertEquals(Manager::EXIT_STATUS_DOWN, $return);117 rewind($this->manager->getOutput()->getStream());118 $outputStr = stream_get_contents($this->manager->getOutput()->getStream());119 $this->assertRegExp('/up 20120111235330 TestMigration/', $outputStr);120 $this->assertRegExp('/down 20120116183504 TestMigration2/', $outputStr);121 }122 public function testGetMigrationsWithDuplicateMigrationVersions()123 {124 $this->setExpectedException(125 'InvalidArgumentException',126 'Duplicate migration - "' . $this->getCorrectedPath(__DIR__ . '/_files/duplicateversions/20120111235330_duplicate_migration_2.php') . '" has the same version as "20120111235330"'127 );128 $config = new Config(array('paths' => array('migrations' => $this->getCorrectedPath(__DIR__ . '/_files/duplicateversions'))));129 $output = new StreamOutput(fopen('php://memory', 'a', false));130 $manager = new Manager($config, $output);131 $manager->getMigrations();132 }133 public function testGetMigrationsWithDuplicateMigrationNames()134 {135 $this->setExpectedException(136 'InvalidArgumentException',137 'Migration "20120111235331_duplicate_migration_name.php" has the same name as "20120111235330_duplicate_migration_name.php"'138 );139 $config = new Config(array('paths' => array('migrations' => $this->getCorrectedPath(__DIR__ . '/_files/duplicatenames'))));140 $output = new StreamOutput(fopen('php://memory', 'a', false));141 $manager = new Manager($config, $output);142 $manager->getMigrations();143 }144 public function testGetMigrationsWithInvalidMigrationClassName()145 {146 $this->setExpectedException(147 'InvalidArgumentException',148 'Could not find class "InvalidClass" in file "' . $this->getCorrectedPath(__DIR__ . '/_files/invalidclassname/20120111235330_invalid_class.php') . '"'149 );150 $config = new Config(array('paths' => array('migrations' => $this->getCorrectedPath(__DIR__ . '/_files/invalidclassname'))));151 $output = new StreamOutput(fopen('php://memory', 'a', false));152 $manager = new Manager($config, $output);153 $manager->getMigrations();154 }155 public function testGetMigrationsWithClassThatDoesntExtendAbstractMigration()156 {157 $this->setExpectedException(158 'InvalidArgumentException',159 'The class "InvalidSuperClass" in file "' . $this->getCorrectedPath(__DIR__ . '/_files/invalidsuperclass/20120111235330_invalid_super_class.php') . '" must extend \Phinx\Migration\AbstractMigration'160 );161 $config = new Config(array('paths' => array('migrations' => $this->getCorrectedPath(__DIR__ . '/_files/invalidsuperclass'))));162 $output = new StreamOutput(fopen('php://memory', 'a', false));163 $manager = new Manager($config, $output);164 $manager->getMigrations();165 }166 public function testGettingAValidEnvironment()167 {168 $this->assertTrue($this->manager->getEnvironment('production') instanceof Environment);169 }170 /**171 * Test that migrating by date chooses the correct172 * migration to point to.173 *174 * @dataProvider migrateDateDataProvider175 */176 public function testMigrationsByDate($availableMigrations, $dateString, $expectedMigration)177 {178 // stub environment179 $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array()));180 $envStub->expects($this->once())181 ->method('getVersions')182 ->will($this->returnValue($availableMigrations));183 $this->manager->setEnvironments(array('mockenv' => $envStub));184 $this->manager->migrateToDateTime('mockenv', new \DateTime($dateString));185 rewind($this->manager->getOutput()->getStream());186 $output = stream_get_contents($this->manager->getOutput()->getStream());187 if (is_null($expectedMigration)) {188 $this->assertEmpty($output);189 } else {190 $this->assertContains($expectedMigration, $output);191 }192 }193 /**194 * Test that migrating by date chooses the correct migration to point to.195 *196 * @dataProvider rollbackDateDataProvider197 */198 public function testRollbacksByDate($availableRollbacks, $dateString, $expectedRollback)199 {200 // stub environment201 $envStub = $this->getMock('\Phinx\Migration\Manager\Environment', array(), array('mockenv', array()));202 $envStub->expects($this->any())203 ->method('getVersions')204 ->will($this->returnValue($availableRollbacks));205 $this->manager->setEnvironments(array('mockenv' => $envStub));206 $this->manager->rollbackToDateTime('mockenv', new \DateTime($dateString));207 rewind($this->manager->getOutput()->getStream());208 $output = stream_get_contents($this->manager->getOutput()->getStream());209 if (is_null($expectedRollback)) {210 $this->assertEmpty($output);211 } else {212 $this->assertContains($expectedRollback, $output);213 }214 }215 /**216 * Migration lists, dates, and expected migrations to point to.217 *...
getVersions
Using AI Code Generation
1$stub = new stub();2$stub->getVersions();3$stub = new stub();4$stub->getVersions();5$stub = new stub();6$stub->getVersions();
getVersions
Using AI Code Generation
1$stub = new stub();2$stub->getVersions();3$stub = new stub();4$stub->getVersions();5$stub = new stub();6$stub->getVersions();7$stub = new stub();8$stub->getVersions();9$stub = new stub();10$stub->getVersions();11$stub = new stub();12$stub->getVersions();13$stub = new stub();14$stub->getVersions();15$stub = new stub();16$stub->getVersions();17$stub = new stub();18$stub->getVersions();19$stub = new stub();20$stub->getVersions();21$stub = new stub();22$stub->getVersions();23$stub = new stub();24$stub->getVersions();25$stub = new stub();26$stub->getVersions();27$stub = new stub();28$stub->getVersions();29$stub = new stub();30$stub->getVersions();31$stub = new stub();32$stub->getVersions();33$stub = new stub();34$stub->getVersions();
getVersions
Using AI Code Generation
1require_once('stub.php');2$stub = new stub();3$stub->getVersions();4require_once('stub.php');5$stub = new stub();6$stub->getVersions();7require_once('stub.php');8$stub = new stub();9$stub->getVersions();10require_once('stub.php');11$stub = new stub();12$stub->getVersions();13require_once('stub.php');14$stub = new stub();15$stub->getVersions();16require_once('stub.php');17$stub = new stub();18$stub->getVersions();19require_once('stub.php');20$stub = new stub();21$stub->getVersions();22require_once('stub.php');23$stub = new stub();24$stub->getVersions();25require_once('stub.php');26$stub = new stub();27$stub->getVersions();28require_once('stub.php');29$stub = new stub();30$stub->getVersions();31require_once('stub.php');32$stub = new stub();33$stub->getVersions();34require_once('stub.php');35$stub = new stub();36$stub->getVersions();37require_once('stub.php');38$stub = new stub();39$stub->getVersions();40require_once('stub.php');41$stub = new stub();42$stub->getVersions();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with getVersions on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!